feat:新增通过角色编码查询所属用户接口
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user