Search in sources :

Example 1 with SysUserScope

use of com.hccake.ballcat.system.model.dto.SysUserScope in project ballcat by ballcat-projects.

the class SysUserController method getUserRoleIds.

/**
 * 获取用户 所拥有的角色ID
 * @param userId userId
 */
@GetMapping("/scope/{userId}")
@PreAuthorize("@per.hasPermission('system:user:grant')")
public R<SysUserScope> getUserRoleIds(@PathVariable("userId") Integer userId) {
    List<SysRole> roleList = sysUserRoleService.listRoles(userId);
    List<String> roleCodes = new ArrayList<>();
    if (CollectionUtil.isNotEmpty(roleList)) {
        roleList.forEach(role -> roleCodes.add(role.getCode()));
    }
    SysUserScope sysUserScope = new SysUserScope();
    sysUserScope.setRoleCodes(roleCodes);
    return R.ok(sysUserScope);
}
Also used : SysUserScope(com.hccake.ballcat.system.model.dto.SysUserScope) SysRole(com.hccake.ballcat.system.model.entity.SysRole) ArrayList(java.util.ArrayList) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

SysUserScope (com.hccake.ballcat.system.model.dto.SysUserScope)1 SysRole (com.hccake.ballcat.system.model.entity.SysRole)1 ArrayList (java.util.ArrayList)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1