|
@@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.PostService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Parameters;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -134,40 +135,34 @@ public class EmployeeInfoController {
|
|
|
|
|
|
|
|
|
@GetMapping("/listForSelectEmployee")
|
|
|
- @Operation(summary = "获得可选择的员工信息列表用于选择业务人")
|
|
|
+ @Operation(summary = "获得可选择的员工信息列表,用于选择业务人或审批人等")
|
|
|
+ @Parameter(name = "auth", description = "是否有权限,0无 1有", required = true)
|
|
|
+ @Parameter(name = "name", description = "员工姓名", required = false)
|
|
|
+ @Parameter(name = "deptId", description = "部门ID", required = false)
|
|
|
+ @Parameter(name = "phone", description = "员工手机号", required = false)
|
|
|
// @PreAuthorize("@ss.hasPermission('employee:info:listForSelectEmployee')")
|
|
|
- public CommonResult<List<EmployeeInfoRespVO>> getInfoListForSelectEmployee() {
|
|
|
- List<EmployeeInfoDO> listResult = infoService.getInfoListForSelectEmployee();
|
|
|
+ public CommonResult<List<EmployeeInfoRespVO>> getInfoListForSelectEmployee(@RequestParam(value = "auth", required = false) String auth,
|
|
|
+ @RequestParam(value = "name", required = false) String name,
|
|
|
+ @RequestParam(value = "deptId", required = false) Long deptId,
|
|
|
+ @RequestParam(value = "phone", required = false) String phone) {
|
|
|
+ // 查询员工信息列表
|
|
|
+ List<EmployeeInfoDO> listResult = infoService.getInfoListForSelectEmployee(auth, name, deptId, phone);
|
|
|
+ // 如果查询结果为空,则返回一个空列表
|
|
|
if (CollUtil.isEmpty(listResult)) {
|
|
|
return success(new ArrayList<>());
|
|
|
}
|
|
|
- // 拼接数据
|
|
|
- Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
- convertList(listResult, EmployeeInfoDO::getDeptId));
|
|
|
-
|
|
|
- List<Long> postIdList = listResult.stream().map(EmployeeInfoDO::getPostId).collect(Collectors.toList());
|
|
|
- List<PostDO> postList = postService.getPostList(postIdList);
|
|
|
- Map<Long, PostDO> postMap = CollectionUtils.convertMap(postList, PostDO::getId);
|
|
|
-
|
|
|
- return success(EmployeeConvert.INSTANCE.convertList(listResult, deptMap, postMap));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/listForSelectAssigns")
|
|
|
- @Operation(summary = "获得员工信息列表用于选择审批人等")
|
|
|
- // @PreAuthorize("@ss.hasPermission('employee:info:listForSelectAssigns')")
|
|
|
- public CommonResult<List<EmployeeInfoRespVO>> getInfoListForSelectAssigns() {
|
|
|
- List<EmployeeInfoDO> listResult = infoService.getInfoListForSelectAssigns();
|
|
|
- if (CollUtil.isEmpty(listResult)) {
|
|
|
- return success(new ArrayList<>());
|
|
|
- }
|
|
|
- // 拼接数据
|
|
|
+ // 将查询结果中的部门ID映射为部门信息
|
|
|
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
convertList(listResult, EmployeeInfoDO::getDeptId));
|
|
|
|
|
|
+ // 获取所有员工的岗位ID列表
|
|
|
List<Long> postIdList = listResult.stream().map(EmployeeInfoDO::getPostId).collect(Collectors.toList());
|
|
|
+ // 根据岗位ID列表查询岗位信息
|
|
|
List<PostDO> postList = postService.getPostList(postIdList);
|
|
|
+ // 将岗位ID与岗位信息映射
|
|
|
Map<Long, PostDO> postMap = CollectionUtils.convertMap(postList, PostDO::getId);
|
|
|
|
|
|
+ // 将员工信息、部门信息和岗位信息合并转换为前端所需的格式,并返回
|
|
|
return success(EmployeeConvert.INSTANCE.convertList(listResult, deptMap, postMap));
|
|
|
}
|
|
|
|