Search in sources :

Example 11 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.

the class SysRoleServiceImpl method checkRoleNameUnique.

/**
 * 校验角色名称是否唯一
 *
 * @param role 角色信息
 * @return 结果
 */
@Override
public String checkRoleNameUnique(SysRole role) {
    Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
    SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
    if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysRole(com.ruoyi.common.core.domain.entity.SysRole)

Example 12 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.

the class SysRoleServiceImpl method selectRolesByUserId.

/**
 * 根据用户ID查询角色
 *
 * @param userId 用户ID
 * @return 角色列表
 */
@Override
public List<SysRole> selectRolesByUserId(Long userId) {
    List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
    List<SysRole> roles = selectRoleAll();
    for (SysRole role : roles) {
        for (SysRole userRole : userRoles) {
            if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) {
                role.setFlag(true);
                break;
            }
        }
    }
    return roles;
}
Also used : SysRole(com.ruoyi.common.core.domain.entity.SysRole)

Example 13 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.

the class SysRoleServiceImpl method checkRoleKeyUnique.

/**
 * 校验角色权限是否唯一
 *
 * @param role 角色信息
 * @return 结果
 */
@Override
public String checkRoleKeyUnique(SysRole role) {
    Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
    SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
    if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysRole(com.ruoyi.common.core.domain.entity.SysRole)

Example 14 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.

the class SysRoleServiceImpl method selectRolePermissionByUserId.

/**
 * 根据用户ID查询权限
 *
 * @param userId 用户ID
 * @return 权限列表
 */
@Override
public Set<String> selectRolePermissionByUserId(Long userId) {
    List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
    Set<String> permsSet = new HashSet<>();
    for (SysRole perm : perms) {
        if (StringUtils.isNotNull(perm)) {
            permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
        }
    }
    return permsSet;
}
Also used : SysRole(com.ruoyi.common.core.domain.entity.SysRole) HashSet(java.util.HashSet)

Example 15 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.

the class SysUserServiceImpl method selectUserRoleGroup.

/**
 * 查询用户所属角色组
 *
 * @param userName 用户名
 * @return 结果
 */
@Override
public String selectUserRoleGroup(String userName) {
    List<SysRole> list = roleMapper.selectRolesByUserName(userName);
    StringBuffer idsStr = new StringBuffer();
    for (SysRole role : list) {
        idsStr.append(role.getRoleName()).append(",");
    }
    if (StringUtils.isNotEmpty(idsStr.toString())) {
        return idsStr.substring(0, idsStr.length() - 1);
    }
    return idsStr.toString();
}
Also used : SysRole(com.ruoyi.common.core.domain.entity.SysRole)

Aggregations

SysRole (com.ruoyi.common.core.domain.entity.SysRole)44 SysUser (com.ruoyi.common.core.domain.entity.SysUser)15 Log (com.ruoyi.common.annotation.Log)9 UserConstants (com.ruoyi.common.constant.UserConstants)9 BaseController (com.ruoyi.common.core.controller.BaseController)9 TableDataInfo (com.ruoyi.common.core.page.TableDataInfo)9 BusinessType (com.ruoyi.common.enums.BusinessType)9 ServiceException (com.ruoyi.common.exception.ServiceException)9 StringUtils (com.ruoyi.common.utils.StringUtils)9 ExcelUtil (com.ruoyi.common.utils.poi.ExcelUtil)9 ISysPostService (com.ruoyi.system.service.ISysPostService)9 ISysRoleService (com.ruoyi.system.service.ISysRoleService)9 ISysUserService (com.ruoyi.system.service.ISysUserService)9 List (java.util.List)9 Collectors (java.util.stream.Collectors)9 Validated (org.springframework.validation.annotation.Validated)9 MultipartFile (org.springframework.web.multipart.MultipartFile)9 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)4 BCrypt (cn.dev33.satoken.secure.BCrypt)4