|
@@ -1,5 +1,11 @@
|
|
|
package cn.iocoder.yudao.module.attendance.service.business;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|
|
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
+import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
|
+import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
|
+import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
@@ -28,12 +34,38 @@ public class AttendanceBusinessServiceImpl implements AttendanceBusinessService
|
|
|
|
|
|
@Resource
|
|
|
private AttendanceBusinessMapper businessMapper;
|
|
|
+ @Resource
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
+ @Resource
|
|
|
+ private FileApi fileApi;
|
|
|
|
|
|
@Override
|
|
|
public Long createBusiness(AttendanceBusinessSaveReqVO createReqVO) {
|
|
|
+
|
|
|
+ LoginUser user = SecurityFrameworkUtils.getLoginUser();
|
|
|
+ Long tenantId = user != null && user.getTenantId() != null ? user.getTenantId() : 0L;
|
|
|
+ Long userId = user != null && user.getId() != null ? user.getId() : 0L;
|
|
|
+ createReqVO.setTenantId(tenantId);
|
|
|
+
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(createReqVO.getEmployeeId());
|
|
|
+ createReqVO.setEmployeeId(employee.getId());
|
|
|
+ createReqVO.setEmployeeName(employee.getName());
|
|
|
+ createReqVO.setEmployeePhone(employee.getPhone());
|
|
|
+ createReqVO.setDeptId(employee.getDeptId());
|
|
|
+ createReqVO.setPosition(employee.getPosition());
|
|
|
+
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(userId);
|
|
|
+ if (loginEmployee != null) {
|
|
|
+ createReqVO.setCreatorEmployeeId(loginEmployee.getId());
|
|
|
+ createReqVO.setCreatorEmployeeName(loginEmployee.getName());
|
|
|
+ }
|
|
|
|
|
|
+ String infoId = IdUtil.fastSimpleUUID();
|
|
|
+ createReqVO.setBusinessId(infoId);
|
|
|
AttendanceBusinessDO business = BeanUtils.toBean(createReqVO, AttendanceBusinessDO.class);
|
|
|
businessMapper.insert(business);
|
|
|
+
|
|
|
+ fileApi.updateFileBiz(createReqVO.getFileIdList(), infoId);
|
|
|
|
|
|
return business.getId();
|
|
|
}
|
|
@@ -42,6 +74,15 @@ public class AttendanceBusinessServiceImpl implements AttendanceBusinessService
|
|
|
public void updateBusiness(AttendanceBusinessSaveReqVO updateReqVO) {
|
|
|
|
|
|
validateBusinessExists(updateReqVO.getId());
|
|
|
+
|
|
|
+ fileApi.updateFileBiz(updateReqVO.getFileIdList(), updateReqVO.getBusinessId());
|
|
|
+
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(updateReqVO.getEmployeeId());
|
|
|
+ updateReqVO.setEmployeeId(employee.getId());
|
|
|
+ updateReqVO.setEmployeeName(employee.getName());
|
|
|
+ updateReqVO.setEmployeePhone(employee.getPhone());
|
|
|
+ updateReqVO.setDeptId(employee.getDeptId());
|
|
|
+ updateReqVO.setPosition(employee.getPosition());
|
|
|
|
|
|
AttendanceBusinessDO updateObj = BeanUtils.toBean(updateReqVO, AttendanceBusinessDO.class);
|
|
|
businessMapper.updateById(updateObj);
|