use of com.dimple.project.system.domain.Role in project DimpleBlog by martin-chips.
the class RoleServiceImpl method checkRoleNameUnique.
@Override
public String checkRoleNameUnique(Role role) {
Long roleId = StringUtils.isNull(role.getId()) ? -1L : role.getId();
Role info = roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && info.getId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
use of com.dimple.project.system.domain.Role in project DimpleBlog by martin-chips.
the class RoleServiceImpl method checkRoleKeyUnique.
@Override
public String checkRoleKeyUnique(Role role) {
Long roleId = StringUtils.isNull(role.getId()) ? -1L : role.getId();
Role info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
if (StringUtils.isNotNull(info) && info.getId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
use of com.dimple.project.system.domain.Role in project DimpleBlog by martin-chips.
the class RoleServiceImpl method selectRolePermissionByUserId.
@Override
public Set<String> selectRolePermissionByUserId(Long userId) {
List<Role> perms = roleMapper.selectRolePermissionByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (Role perm : perms) {
if (StringUtils.isNotNull(perm)) {
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
return permsSet;
}
use of com.dimple.project.system.domain.Role in project DimpleBlog by martin-chips.
the class RoleServiceImpl method deleteRoleByIds.
@Override
public int deleteRoleByIds(String ids) {
Long[] roleIds = ConvertUtils.toLongArray(ids);
for (Long roleId : roleIds) {
checkRoleAllowed(new Role(roleId));
Role role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0) {
throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
String loginUsername = SecurityUtils.getUsername();
return roleMapper.deleteRoleByIds(roleIds, loginUsername);
}
use of com.dimple.project.system.domain.Role in project DimpleBlog by martin-chips.
the class UserServiceImpl method selectUserRoleGroup.
@Override
public String selectUserRoleGroup(String userName) {
List<Role> list = roleMapper.selectRolesByUserName(userName);
StringBuilder idsStr = new StringBuilder();
for (Role role : list) {
idsStr.append(role.getRoleName()).append(",");
}
if (StringUtils.isNotEmpty(idsStr.toString())) {
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
}
Aggregations