mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	[fit] 优化其他合同关联功能
This commit is contained in:
		| @@ -27,6 +27,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||||
| import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; | ||||
| import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||||
|  | ||||
|  | ||||
| @Tag(name = "管理后台 - 外部合同") | ||||
| @@ -42,14 +43,14 @@ public class ExtContractController { | ||||
|     @Operation(summary = "创建外部合同") | ||||
|     @PreAuthorize("@ss.hasPermission('cms-ext:ext-contract:create')") | ||||
|     public CommonResult<Long> createExtContract(@Valid @RequestBody ExtContractSaveReqVO createReqVO) { | ||||
|         return success(extContractService.createExtContract(createReqVO)); | ||||
|         return success(extContractService.createExtContract(getLoginUserId(),createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新外部合同") | ||||
|     @PreAuthorize("@ss.hasPermission('cms-ext:ext-contract:update')") | ||||
|     public CommonResult<Boolean> updateExtContract(@Valid @RequestBody ExtContractSaveReqVO updateReqVO) { | ||||
|         extContractService.updateExtContract(updateReqVO); | ||||
|         extContractService.updateExtContract(getLoginUserId(),updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -27,6 +27,7 @@ import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
| import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||||
|  | ||||
| @Tag(name = "管理后台 - 外包合同") | ||||
| @RestController | ||||
| @@ -41,14 +42,14 @@ public class OutsContractController { | ||||
|     @Operation(summary = "创建外包合同") | ||||
|     @PreAuthorize("@ss.hasPermission('cms:outs-contract:create')") | ||||
|     public CommonResult<Long> createOutsContract(@Valid @RequestBody OutsContractSaveReqVO createReqVO) { | ||||
|         return success(outsContractService.createOutsContract(createReqVO)); | ||||
|         return success(outsContractService.createOutsContract(getLoginUserId(),createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新外包合同") | ||||
|     @PreAuthorize("@ss.hasPermission('cms:outs-contract:update')") | ||||
|     public CommonResult<Boolean> updateOutsContract(@Valid @RequestBody OutsContractSaveReqVO updateReqVO) { | ||||
|         outsContractService.updateOutsContract(updateReqVO); | ||||
|         outsContractService.updateOutsContract(getLoginUserId(),updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -20,14 +20,14 @@ public interface ContractService { | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createContract(@Valid ContractSaveReqVO createReqVO); | ||||
|     Long createContract(Long loginUserId,@Valid ContractSaveReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新合同 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateContract(@Valid ContractSaveReqVO updateReqVO); | ||||
|     void updateContract(Long loginUserId,@Valid ContractSaveReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除合同 | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.cms.dal.mysql.extcontract.ExtContractMapper; | ||||
| import cn.iocoder.yudao.module.pms.api.ProjectApi; | ||||
| import cn.iocoder.yudao.module.pms.api.project.dto.ProjectDetailRespDTO; | ||||
| import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -24,6 +25,7 @@ import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*; | ||||
| import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; | ||||
|  | ||||
| /** | ||||
|  * 合同 Service 实现类 | ||||
| @@ -42,30 +44,47 @@ public class ContractServiceImpl implements ContractService { | ||||
|     private ProjectApi projectApi; | ||||
|  | ||||
|     @Resource | ||||
|     private ExtContractMapper extContractMapper; | ||||
|     private AdminUserApi adminUserApi; | ||||
|  | ||||
|  | ||||
|     @Override | ||||
|     public Long createContract(ContractSaveReqVO createReqVO) { | ||||
|     public Long createContract(Long loginUserId,ContractSaveReqVO createReqVO) { | ||||
|         if (createReqVO == null){ | ||||
|             throw exception(PARAM_NOT_EXISTS); | ||||
|         } | ||||
|         if (loginUserId == null){ | ||||
|             throw exception(PARAM_NOT_EXISTS); | ||||
|         } | ||||
|         String userName = adminUserApi.getUser(loginUserId).getNickname(); | ||||
|         if (userName == null){ | ||||
|             throw exception(USER_NOT_EXISTS); | ||||
|         } | ||||
|  | ||||
|         ContractDO contract = BeanUtils.toBean(createReqVO, ContractDO.class); | ||||
|         //校验 | ||||
|         //校验,项目是否存在 | ||||
|         projectApi.validProjectExist(contract.getProjectId()); | ||||
|  | ||||
|         contract.setCreator(userName); | ||||
|         contract.setUpdater(userName); | ||||
|         contractMapper.insert(contract); | ||||
|  | ||||
|  | ||||
|         //返回 | ||||
|         return contract.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateContract(ContractSaveReqVO updateReqVO) { | ||||
|     public void updateContract(Long loginUserId,ContractSaveReqVO updateReqVO) { | ||||
|         //校验 | ||||
|         validateContractExists(updateReqVO.getId()); | ||||
|         projectApi.validProjectExist(updateReqVO.getProjectId()); | ||||
|         // 更新 | ||||
|         ContractDO updateObj = BeanUtils.toBean(updateReqVO, ContractDO.class); | ||||
|         String userName = adminUserApi.getUser(loginUserId).getNickname(); | ||||
|         if (userName == null){ | ||||
|             throw exception(USER_NOT_EXISTS); | ||||
|         } | ||||
|         updateObj.setUpdater(userName); | ||||
|         contractMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -22,14 +22,14 @@ public interface ExtContractService { | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createExtContract(@Valid ExtContractSaveReqVO createReqVO); | ||||
|     Long createExtContract(Long loginUserId,@Valid ExtContractSaveReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新外部合同 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateExtContract(@Valid ExtContractSaveReqVO updateReqVO); | ||||
|     void updateExtContract(Long loginUserId,@Valid ExtContractSaveReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除外部合同 | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.cms.dal.mysql.extcontract.ExtContractMapper; | ||||
| import cn.iocoder.yudao.module.pms.api.ProjectApi; | ||||
| import cn.iocoder.yudao.module.pms.api.project.dto.ProjectDetailRespDTO; | ||||
| import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import org.springframework.stereotype.Service; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @@ -23,6 +24,7 @@ import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*; | ||||
| import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; | ||||
|  | ||||
| /** | ||||
|  * 外部合同 Service 实现类 | ||||
| @@ -42,22 +44,32 @@ public class ExtContractServiceImpl implements ExtContractService { | ||||
|     @Resource | ||||
|     private CustomerCompanyMapper customerCompanyMapper; | ||||
|  | ||||
|     @Resource | ||||
|     private AdminUserApi adminUserApi; | ||||
|  | ||||
|  | ||||
|     @Override | ||||
|     public Long createExtContract(ExtContractSaveReqVO createReqVO) { | ||||
|     public Long createExtContract(Long loginUserId,ExtContractSaveReqVO createReqVO) { | ||||
|         if (createReqVO == null){ | ||||
|             throw exception(PARAM_NOT_EXISTS); | ||||
|         } | ||||
|         ExtContractDO contract = BeanUtils.toBean(createReqVO, ExtContractDO.class); | ||||
|         ExtContractDO extContract = BeanUtils.toBean(createReqVO, ExtContractDO.class); | ||||
|         //校验 | ||||
|         projectApi.validProjectExist(contract.getProjectId()); | ||||
|         extContractMapper.insert(contract); | ||||
|         projectApi.validProjectExist(extContract.getProjectId()); | ||||
|  | ||||
|         String userName = adminUserApi.getUser(loginUserId).getNickname(); | ||||
|         if (userName == null){ | ||||
|             throw exception(USER_NOT_EXISTS); | ||||
|         } | ||||
|         extContract.setCreator(userName); | ||||
|         extContract.setUpdater(userName); | ||||
|         extContractMapper.insert(extContract); | ||||
|         //返回 | ||||
|         return contract.getId(); | ||||
|         return extContract.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateExtContract(ExtContractSaveReqVO updateReqVO) { | ||||
|     public void updateExtContract(Long loginUserId,ExtContractSaveReqVO updateReqVO) { | ||||
|         //校验 | ||||
|         if (updateReqVO == null){ | ||||
|             throw exception(PARAM_NOT_EXISTS); | ||||
| @@ -65,8 +77,13 @@ public class ExtContractServiceImpl implements ExtContractService { | ||||
|  | ||||
|         validateExtContractExists(updateReqVO.getId()); | ||||
|         projectApi.validProjectExist(updateReqVO.getProjectId()); | ||||
|         String userName = adminUserApi.getUser(loginUserId).getNickname(); | ||||
|         if (userName == null){ | ||||
|             throw exception(USER_NOT_EXISTS); | ||||
|         } | ||||
|         // 更新 | ||||
|         ExtContractDO updateObj = BeanUtils.toBean(updateReqVO, ExtContractDO.class); | ||||
|         updateObj.setUpdater(userName); | ||||
|         extContractMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -23,14 +23,14 @@ public interface OutsContractService { | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createOutsContract(@Valid OutsContractSaveReqVO createReqVO); | ||||
|     Long createOutsContract(Long loginUserId,@Valid OutsContractSaveReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新外包合同 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateOutsContract(@Valid OutsContractSaveReqVO updateReqVO); | ||||
|     void updateOutsContract(Long loginUserId,@Valid OutsContractSaveReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除外包合同 | ||||
|   | ||||
| @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.cms.dal.mysql.outscontract.OutsContractMapper; | ||||
| import cn.iocoder.yudao.module.cms.service.contract.ContractService; | ||||
| import cn.iocoder.yudao.module.pms.api.ProjectApi; | ||||
| import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @@ -21,6 +22,7 @@ import java.util.Objects; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*; | ||||
| import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; | ||||
|  | ||||
| /** | ||||
|  * 外包合同 Service 实现类 | ||||
| @@ -40,8 +42,11 @@ public class OutsContractServiceImpl implements OutsContractService { | ||||
|     @Resource | ||||
|     private ProjectApi projectApi; | ||||
|  | ||||
|     @Resource | ||||
|     private AdminUserApi adminUserApi; | ||||
|  | ||||
|     @Override | ||||
|     public Long createOutsContract(OutsContractSaveReqVO createReqVO) { | ||||
|     public Long createOutsContract(Long loginUserId,OutsContractSaveReqVO createReqVO) { | ||||
|  | ||||
|         if (createReqVO == null) { | ||||
|             throw exception(PARAM_NOT_EXISTS); | ||||
| @@ -66,6 +71,14 @@ public class OutsContractServiceImpl implements OutsContractService { | ||||
|         if (!Objects.equals(createReqVO.getName(), contract.getName())) { | ||||
|             throw exception(CONTRACT_NAME_NOT_EXISTS); | ||||
|         } | ||||
|         //TODO 待优化 | ||||
|         String userName = adminUserApi.getUser(loginUserId).getNickname(); | ||||
|         if (userName == null){ | ||||
|             throw exception(USER_NOT_EXISTS); | ||||
|         } | ||||
|         outsContract.setCreator(userName); | ||||
|         outsContract.setUpdater(userName); | ||||
|  | ||||
|  | ||||
|  | ||||
|         outsContractMapper.insert(outsContract); | ||||
| @@ -73,7 +86,7 @@ public class OutsContractServiceImpl implements OutsContractService { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateOutsContract(OutsContractSaveReqVO updateReqVO) { | ||||
|     public void updateOutsContract(Long loginUserId,OutsContractSaveReqVO updateReqVO) { | ||||
|         // 校验 | ||||
|         validateOutsContractExists(updateReqVO.getId()); | ||||
|  | ||||
| @@ -86,8 +99,13 @@ public class OutsContractServiceImpl implements OutsContractService { | ||||
|         if (!Objects.equals(updateReqVO.getProjectId(), outsContractDO.getProjectId())) { | ||||
|             throw exception(PROJECT_NOT_EXISTS); | ||||
|         } | ||||
|         String userName = adminUserApi.getUser(loginUserId).getNickname(); | ||||
|         if (userName == null){ | ||||
|             throw exception(USER_NOT_EXISTS); | ||||
|         } | ||||
|         // 更新 | ||||
|         OutsContractDO updateObj = BeanUtils.toBean(updateReqVO, OutsContractDO.class); | ||||
|         updateObj.setUpdater(userName); | ||||
|         outsContractMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
| @@ -126,6 +144,7 @@ public class OutsContractServiceImpl implements OutsContractService { | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<OutsContractRespVO> getOutsContractPage(OutsContractPageReqVO pageReqVO) { | ||||
|  | ||||
|         if (pageReqVO == null) { | ||||
|             throw exception(PARAM_NOT_EXISTS); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 wyw
					wyw