feat:新增通过角色编码查询所属用户接口

This commit is contained in:
2025-12-30 15:32:04 +08:00
parent 3b133c19dd
commit 6923986805
3 changed files with 25 additions and 0 deletions

View File

@@ -28,13 +28,17 @@ import com.honeycombis.honeycom.spdm.util.PageResult;
import com.honeycombis.honeycom.spdm.util.ResponseR;
import com.honeycombis.honeycom.tenant.entity.SysRoleEntity;
import com.honeycombis.honeycom.tenant.vo.SysRoleVO;
import com.honeycombis.honeycom.tenant.vo.SysStaffVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@RestController
@@ -82,4 +86,16 @@ public class SpdmRoleController {
return ResponseR.ok(role.getData());
}
@Operation(summary = "查询某个角色下的用户列表")
@GetMapping("/getUserByRoleCode")
public ResponseR<List<Long>> getUserByRoleCode(@RequestParam("roleCode") String roleCode, @RequestParam("tenantId") String tenantId) {
R<SysRoleVO> role = remoteRoleServiceFeign.getRoleByRoleCode(roleCode, tenantId);
R<Map<Long, List<SysStaffVO>>> mapR = remoteRoleServiceFeign.findByRoleIds(Arrays.asList(role.getData().getRoleId()), tenantId);
List<SysStaffVO> staffList = mapR.getData().get(role.getData().getRoleId());
if (CollectionUtils.isNotEmpty(staffList)) {
return ResponseR.ok(staffList.stream().map(SysStaffVO::getUserId).toList());
}
return ResponseR.ok();
}
}

View File

@@ -8,11 +8,16 @@ import com.honeycombis.honeycom.common.feign.config.FeignConfig;
import com.honeycombis.honeycom.spdm.dto.RolePageQueryDto;
import com.honeycombis.honeycom.tenant.entity.SysRoleEntity;
import com.honeycombis.honeycom.tenant.vo.SysRoleVO;
import com.honeycombis.honeycom.tenant.vo.SysStaffVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
@FeignClient(contextId = "remoteRoleService", value = ServiceNameConstants.TENANT_SERVICE, configuration = FeignConfig.class)
@@ -30,4 +35,7 @@ public interface RemoteRoleServiceFeign {
@GetMapping("/sysRole/getByRoleName/{roleName}")
R<SysRoleVO> getRoleByRoleName(@PathVariable("roleName") String roleName, @RequestHeader(CommonConstants.TENANT_ID) String tenantId);
@GetMapping("/sysStaff/findByRoleIds")
R<Map<Long, List<SysStaffVO>>> findByRoleIds(@RequestParam("roleIds") List<Long> roleIds, @RequestHeader(CommonConstants.TENANT_ID) String tenantId);
}

View File

@@ -223,6 +223,7 @@ public class SysStaffController {
@Operation(summary = "根据角色ID集合获取员工列表", description = "根据角色ID集合获取员工列表")
@GetMapping("/findByRoleIds")
@Inner(false)
public R<Map<Long, List<SysStaffVO>>> findByRoleIds(@RequestParam("roleIds") List<Long> roleIds) {
return R.ok(sysStaffService.findByRoleIds(roleIds));
}