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);
}
Aggregations