Search in sources :

Example 1 with Role

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;
}
Also used : Role(com.dimple.project.system.domain.Role)

Example 2 with Role

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;
}
Also used : Role(com.dimple.project.system.domain.Role)

Example 3 with Role

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;
}
Also used : Role(com.dimple.project.system.domain.Role) HashSet(java.util.HashSet)

Example 4 with Role

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);
}
Also used : Role(com.dimple.project.system.domain.Role) CustomException(com.dimple.common.exception.CustomException)

Example 5 with Role

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();
}
Also used : Role(com.dimple.project.system.domain.Role) UserRole(com.dimple.project.system.domain.UserRole)

Aggregations

Role (com.dimple.project.system.domain.Role)5 CustomException (com.dimple.common.exception.CustomException)1 UserRole (com.dimple.project.system.domain.UserRole)1 HashSet (java.util.HashSet)1