| | |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.permission.RoleApi; |
| | | import cn.iocoder.yudao.module.system.api.permission.dto.RoleRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.storage.dto.StorageBlobRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserCreateReqDTO; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserUpdateReqDTO; |
| | |
| | | @Resource |
| | | private RoleApi roleApi; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | @Resource |
| | | @Lazy // 自注入需延迟加载,否则 bean 被代理包装后注入原始版本导致启动失败 |
| | | private HrmEmployeeService self; |
| | | |
| | |
| | | } |
| | | employeeMapper.insert(employee); |
| | | Long employeeId = employee.getId(); |
| | | // 绑定附件 |
| | | storageAttachmentApi.bindAttachments("file", "hrm_employee", employeeId, createReqVO.getBlobIds()); |
| | | // 7. 同步添加教育经历 |
| | | if (CollUtil.isNotEmpty(createReqVO.getEducations())) { |
| | | createReqVO.getEducations().forEach(educationVO -> { |
| | |
| | | syncWorkHistoryList(employeeId, updateReqVO.getWorkHistories()); |
| | | // 同步紧急联系人 |
| | | syncEmergencyContactList(employeeId, updateReqVO.getEmergencyContacts()); |
| | | // 更新附件 |
| | | storageAttachmentApi.updateAttachments("file", "hrm_employee", employeeId, updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | private void syncEducationList(Long employeeId, List<HrmEmployeeEducationSaveReqVO> newList) { |
| | |
| | | educationMapper.deleteByEmployeeId(id); |
| | | workHistoryMapper.deleteByEmployeeId(id); |
| | | emergencyContactMapper.deleteByEmployeeId(id); |
| | | // 删除附件 |
| | | storageAttachmentApi.deleteAttachmentsByRecord("hrm_employee", id); |
| | | // 删除员工 |
| | | employeeMapper.deleteById(id); |
| | | } |
| | |
| | | respVO.setRoleNames(roles.stream().map(RoleRespDTO::getName).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | // 填充附件 |
| | | respVO.setAttachmentList(storageAttachmentApi.listAttachments("hrm_employee", id)); |
| | | return respVO; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public PageResult<HrmEmployeeDO> getEmployeePage(HrmEmployeePageReqVO pageReqVO) { |
| | | if (pageReqVO.getDeptId() != null) { |
| | | // 选中部门时,连带查询其所有子部门的员工(含自身) |
| | | List<DeptRespDTO> childDepts = deptApi.getChildDeptList(pageReqVO.getDeptId()); |
| | | Set<Long> deptIds = new LinkedHashSet<>(); |
| | | deptIds.add(pageReqVO.getDeptId()); |
| | | if (CollUtil.isNotEmpty(childDepts)) { |
| | | childDepts.forEach(dept -> deptIds.add(dept.getId())); |
| | | } |
| | | return employeeMapper.selectPageByDeptIds(pageReqVO, deptIds); |
| | | } |
| | | return employeeMapper.selectPage(pageReqVO); |
| | | } |
| | | |