| | |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeMapper; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeWorkHistoryMapper; |
| | | import cn.iocoder.yudao.module.hrm.dal.redis.HrmNoRedisDAO; |
| | | import cn.iocoder.yudao.module.infra.api.config.ConfigApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.PostApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| | |
| | | @Resource |
| | | private MesCalTeamApi mesCalTeamApi; |
| | | @Resource |
| | | private ConfigApi configApi; |
| | | |
| | | /** |
| | | * 用户初始密码的系统参数配置项 |
| | | */ |
| | | private static final String USER_INIT_PASSWORD_KEY = "system.user.init-password"; |
| | | @Resource |
| | | @Lazy // 自注入需延迟加载,否则 bean 被代理包装后注入原始版本导致启动失败 |
| | | private HrmEmployeeService self; |
| | | |
| | |
| | | userCreateReqDTO.setDeptId(createReqVO.getDeptId()); |
| | | userCreateReqDTO.setPostIds(Collections.singleton(createReqVO.getPostId())); |
| | | userCreateReqDTO.setMobile(createReqVO.getPhone()); |
| | | userCreateReqDTO.setPassword(createReqVO.getPhone()); |
| | | // 初始密码:优先用导入/新增时指定的密码,否则读取系统参数;两者都没有则报错 |
| | | userCreateReqDTO.setPassword(resolveInitialPassword(createReqVO.getPassword())); |
| | | userCreateReqDTO.setSex(createReqVO.getGender()); |
| | | userCreateReqDTO.setEmail(createReqVO.getEmail()); |
| | | userCreateReqDTO.setRemark(createReqVO.getRemark()); |
| | |
| | | } |
| | | employeeMapper.updateById(updateObj); |
| | | Long employeeId = updateReqVO.getId(); |
| | | |
| | | // 同步系统用户密码:仅当显式填写了密码时才更新,未填写保持原密码不变 |
| | | if (StrUtil.isNotBlank(updateReqVO.getPassword()) && employee.getUserId() != null) { |
| | | adminUserApi.updateUserPassword(employee.getUserId(), updateReqVO.getPassword()); |
| | | } |
| | | |
| | | // 同步教育经历 |
| | | syncEducationList(employeeId, updateReqVO.getEducations()); |
| | |
| | | return respVO; |
| | | } |
| | | |
| | | /** |
| | | * 解析员工初始密码: |
| | | * 1. 导入/新增时显式指定了密码,优先使用; |
| | | * 2. 未指定则读取系统参数 {@code system.user.init-password}; |
| | | * 3. 两者都没有时明确报错,避免悄悄用手机号等弱口令兜底。 |
| | | */ |
| | | private String resolveInitialPassword(String specifiedPassword) { |
| | | if (StrUtil.isNotBlank(specifiedPassword)) { |
| | | return specifiedPassword; |
| | | } |
| | | String initPassword = configApi.getConfigValueByKey(USER_INIT_PASSWORD_KEY); |
| | | if (StrUtil.isBlank(initPassword)) { |
| | | throw exception(EMPLOYEE_INIT_PASSWORD_NOT_CONFIGURED); |
| | | } |
| | | return initPassword; |
| | | } |
| | | |
| | | private HrmEmployeeSaveReqVO buildImportSaveReqVO(HrmEmployeeImportExcelVO importEmployee, |
| | | Long deptId, Long postId, Set<Long> roleIds) { |
| | | if (StrUtil.isBlank(importEmployee.getName())) { |
| | |
| | | reqVO.setName(importEmployee.getName()); |
| | | reqVO.setGender(importEmployee.getGender() != null ? importEmployee.getGender() : 1); // 默认男 |
| | | reqVO.setPhone(importEmployee.getPhone()); |
| | | reqVO.setPassword(importEmployee.getPassword()); |
| | | reqVO.setDeptId(deptId); |
| | | reqVO.setPostId(postId); |
| | | reqVO.setRoleIds(CollUtil.isEmpty(roleIds) ? null : new ArrayList<>(roleIds)); |