| | |
| | | } |
| | | |
| | | @GetMapping("/list-by-role-code") |
| | | @Operation(summary = "通过角色标识获取用户精简信息列表", description = "只包含拥有该角色的用户,主要用于前端的下拉选项") |
| | | @Parameter(name = "code", description = "角色标识", required = true, example = "admin") |
| | | @Operation(summary = "通过角色标识获取用户精简信息列表", description = "只包含拥有这些角色的用户,主要用于前端的下拉选项。支持逗号分隔的多个角色标识") |
| | | @Parameter(name = "code", description = "角色标识,支持多个,逗号分隔", required = true, example = "admin,user") |
| | | public CommonResult<List<UserSimpleRespVO>> getSimpleUserListByRoleCode( |
| | | @RequestParam("code") String code) { |
| | | RoleDO role = roleService.getRoleByCode(code); |
| | | if (role == null) { |
| | | if (StrUtil.isBlank(code)) { |
| | | return success(Collections.emptyList()); |
| | | } |
| | | Set<Long> userIds = permissionService.getUserRoleIdListByRoleId(Collections.singleton(role.getId())); |
| | | List<String> codes = StrUtil.split(code, ","); |
| | | List<RoleDO> roles = roleService.getRoleListByCodes(codes); |
| | | if (CollUtil.isEmpty(roles)) { |
| | | return success(Collections.emptyList()); |
| | | } |
| | | Set<Long> userIds = permissionService.getUserRoleIdListByRoleId(convertList(roles, RoleDO::getId)); |
| | | if (CollUtil.isEmpty(userIds)) { |
| | | return success(Collections.emptyList()); |
| | | } |