mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-13 00:54:59 +08:00
[feat] 新增外包合同关联功能
This commit is contained in:
parent
a224d73203
commit
8ebbf12016
@ -23,6 +23,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
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.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 合同管理")
|
@Tag(name = "管理后台 - 合同管理")
|
||||||
@RestController
|
@RestController
|
||||||
@ -37,14 +38,14 @@ public class ContractController {
|
|||||||
@Operation(summary = "创建合同")
|
@Operation(summary = "创建合同")
|
||||||
@PreAuthorize("@ss.hasPermission('cms:contract:create')")
|
@PreAuthorize("@ss.hasPermission('cms:contract:create')")
|
||||||
public CommonResult<Long> createContract(@Valid @RequestBody ContractSaveReqVO createReqVO) {
|
public CommonResult<Long> createContract(@Valid @RequestBody ContractSaveReqVO createReqVO) {
|
||||||
return success(contractService.createContract(createReqVO));
|
return success(contractService.createContract(getLoginUserId(),createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新合同")
|
@Operation(summary = "更新合同")
|
||||||
@PreAuthorize("@ss.hasPermission('cms:contract:update')")
|
@PreAuthorize("@ss.hasPermission('cms:contract:update')")
|
||||||
public CommonResult<Boolean> updateContract(@Valid @RequestBody ContractSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateContract(@Valid @RequestBody ContractSaveReqVO updateReqVO) {
|
||||||
contractService.updateContract(updateReqVO);
|
contractService.updateContract(getLoginUserId(),updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
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.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 外包合同关联")
|
@Tag(name = "管理后台 - 外包合同关联")
|
||||||
@RestController
|
@RestController
|
||||||
@ -40,14 +41,14 @@ public class ContractOutsController {
|
|||||||
@Operation(summary = "创建外包合同关联")
|
@Operation(summary = "创建外包合同关联")
|
||||||
@PreAuthorize("@ss.hasPermission('cms:contract-outs:create')")
|
@PreAuthorize("@ss.hasPermission('cms:contract-outs:create')")
|
||||||
public CommonResult<Long> createContractOuts(@Valid @RequestBody ContractOutsSaveReqVO createReqVO) {
|
public CommonResult<Long> createContractOuts(@Valid @RequestBody ContractOutsSaveReqVO createReqVO) {
|
||||||
return success(contractOutsService.createContractOuts(createReqVO));
|
return success(contractOutsService.createContractOuts(getLoginUserId(),createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新外包合同关联")
|
@Operation(summary = "更新外包合同关联")
|
||||||
@PreAuthorize("@ss.hasPermission('cms:contract-outs:update')")
|
@PreAuthorize("@ss.hasPermission('cms:contract-outs:update')")
|
||||||
public CommonResult<Boolean> updateContractOuts(@Valid @RequestBody ContractOutsSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateContractOuts(@Valid @RequestBody ContractOutsSaveReqVO updateReqVO) {
|
||||||
contractOutsService.updateContractOuts(updateReqVO);
|
contractOutsService.updateContractOuts(getLoginUserId(),updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ public class ContractOutsController {
|
|||||||
return success(BeanUtils.toBean(contractOuts, ContractOutsRespVO.class));
|
return success(BeanUtils.toBean(contractOuts, ContractOutsRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得外包合同关联分页")
|
@Operation(summary = "获得外包合同关联分页")
|
||||||
@PreAuthorize("@ss.hasPermission('cms:contract-outs:query')")
|
@PreAuthorize("@ss.hasPermission('cms:contract-outs:query')")
|
||||||
|
@ -23,25 +23,5 @@ public class ContractOutsPageReqVO extends PageParam {
|
|||||||
@Schema(description = "外包合同id", example = "9277")
|
@Schema(description = "外包合同id", example = "9277")
|
||||||
private Long outsContractId;
|
private Long outsContractId;
|
||||||
|
|
||||||
@Schema(description = "创建人")
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] createTime;
|
|
||||||
|
|
||||||
@Schema(description = "更新人")
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
@Schema(description = "更新时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] updateTime;
|
|
||||||
|
|
||||||
@Schema(description = "是否删除")
|
|
||||||
private Boolean delete;
|
|
||||||
|
|
||||||
@Schema(description = "租户id", example = "15943")
|
|
||||||
private Long tenantId;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -5,17 +5,11 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 外包合同关联 Response VO")
|
@Schema(description = "管理后台 - 外包合同关联 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class ContractOutsRespVO {
|
public class ContractOutsRespVO {
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "7688")
|
|
||||||
@ExcelProperty("主键")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "合同id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16187")
|
@Schema(description = "合同id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16187")
|
||||||
@ExcelProperty("合同id")
|
@ExcelProperty("合同id")
|
||||||
private Long contractId;
|
private Long contractId;
|
||||||
@ -24,28 +18,6 @@ public class ContractOutsRespVO {
|
|||||||
@ExcelProperty("外包合同id")
|
@ExcelProperty("外包合同id")
|
||||||
private Long outsContractId;
|
private Long outsContractId;
|
||||||
|
|
||||||
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@ExcelProperty("创建人")
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
@Schema(description = "更新人", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@ExcelProperty("更新人")
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
@Schema(description = "更新时间")
|
|
||||||
@ExcelProperty("更新时间")
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
@Schema(description = "是否删除", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@ExcelProperty("是否删除")
|
|
||||||
private Boolean delete;
|
|
||||||
|
|
||||||
@Schema(description = "租户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15943")
|
|
||||||
@ExcelProperty("租户id")
|
|
||||||
private Long tenantId;
|
|
||||||
|
|
||||||
}
|
}
|
@ -22,28 +22,4 @@ public class ContractOutsSaveReqVO {
|
|||||||
@NotNull(message = "外包合同id不能为空")
|
@NotNull(message = "外包合同id不能为空")
|
||||||
private Long outsContractId;
|
private Long outsContractId;
|
||||||
|
|
||||||
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotEmpty(message = "创建人不能为空")
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
@Schema(description = "更新人", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotEmpty(message = "更新人不能为空")
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
@Schema(description = "更新时间")
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
@Schema(description = "是否删除", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotNull(message = "是否删除不能为空")
|
|
||||||
private Boolean delete;
|
|
||||||
|
|
||||||
@Schema(description = "租户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15943")
|
|
||||||
@NotNull(message = "租户id不能为空")
|
|
||||||
private Long tenantId;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -47,7 +47,7 @@ public class ContractOutsDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 是否删除
|
* 是否删除
|
||||||
*/
|
*/
|
||||||
private Boolean delete;
|
private Boolean deleted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户id
|
* 租户id
|
||||||
|
@ -19,14 +19,14 @@ public interface ContractOutsService {
|
|||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
Long createContractOuts(@Valid ContractOutsSaveReqVO createReqVO);
|
Long createContractOuts(Long loginUserId ,@Valid ContractOutsSaveReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新外包合同关联
|
* 更新外包合同关联
|
||||||
*
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateContractOuts(@Valid ContractOutsSaveReqVO updateReqVO);
|
void updateContractOuts(Long loginUserId,@Valid ContractOutsSaveReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除外包合同关联
|
* 删除外包合同关联
|
||||||
|
@ -6,13 +6,16 @@ import cn.iocoder.yudao.module.cms.controller.admin.contractouts.vo.ContractOuts
|
|||||||
import cn.iocoder.yudao.module.cms.controller.admin.contractouts.vo.ContractOutsSaveReqVO;
|
import cn.iocoder.yudao.module.cms.controller.admin.contractouts.vo.ContractOutsSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.cms.dal.dataobject.contractouts.ContractOutsDO;
|
import cn.iocoder.yudao.module.cms.dal.dataobject.contractouts.ContractOutsDO;
|
||||||
import cn.iocoder.yudao.module.cms.dal.mysql.contractouts.ContractOutsMapper;
|
import cn.iocoder.yudao.module.cms.dal.mysql.contractouts.ContractOutsMapper;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*;
|
||||||
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.CONTRACT_OUTS_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 外包合同关联 Service 实现类
|
* 外包合同关联 Service 实现类
|
||||||
@ -26,8 +29,11 @@ public class ContractOutsServiceImpl implements ContractOutsService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ContractOutsMapper contractOutsMapper;
|
private ContractOutsMapper contractOutsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createContractOuts(ContractOutsSaveReqVO createReqVO) {
|
public Long createContractOuts(Long loginUserId, ContractOutsSaveReqVO createReqVO) {
|
||||||
ContractOutsDO outsDO = BeanUtils.toBean(createReqVO, ContractOutsDO.class);
|
ContractOutsDO outsDO = BeanUtils.toBean(createReqVO, ContractOutsDO.class);
|
||||||
Long contractId = createReqVO.getContractId();
|
Long contractId = createReqVO.getContractId();
|
||||||
Long outsContractId = createReqVO.getOutsContractId();
|
Long outsContractId = createReqVO.getOutsContractId();
|
||||||
@ -38,17 +44,48 @@ public class ContractOutsServiceImpl implements ContractOutsService {
|
|||||||
throw exception(CONTRACT_OUTS_NOT_EXISTS);
|
throw exception(CONTRACT_OUTS_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
contractOutsMapper.insert(outsDO);
|
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||||
|
//用户不存在
|
||||||
|
if (userName == null || userName.isEmpty()) {
|
||||||
|
throw exception(USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
//如果这条记录不存在,则创建者就是登陆者,如果存在,只更新更新者,创建者不再改变
|
||||||
|
QueryWrapper<ContractOutsDO> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("contract_id", contractId);
|
||||||
|
queryWrapper.eq("outs_contract_id", outsContractId);
|
||||||
|
Long count = contractOutsMapper.selectCount(queryWrapper);
|
||||||
|
if (count >= 1) {
|
||||||
|
throw exception(CONTRACT_OUTS_ALREADY_EXISTS);
|
||||||
|
}
|
||||||
|
ContractOutsDO contractOutsDO = contractOutsMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if (contractOutsDO == null) {
|
||||||
|
outsDO.setCreator(userName);
|
||||||
|
outsDO.setUpdater(userName);
|
||||||
|
}
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
return createReqVO.getId();
|
return (long) contractOutsMapper.insert(outsDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateContractOuts(ContractOutsSaveReqVO updateReqVO) {
|
public void updateContractOuts(Long loginUserId,ContractOutsSaveReqVO updateReqVO) {
|
||||||
|
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateContractOutsExists(updateReqVO.getId());
|
validateContractOutsExists(updateReqVO.getId());
|
||||||
|
if (loginUserId == null){
|
||||||
|
throw exception(USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
// 更新
|
// 更新
|
||||||
ContractOutsDO updateObj = BeanUtils.toBean(updateReqVO, ContractOutsDO.class);
|
ContractOutsDO updateObj = BeanUtils.toBean(updateReqVO, ContractOutsDO.class);
|
||||||
|
//校验
|
||||||
|
ContractOutsDO contractOutsDO = contractOutsMapper.selectById(updateObj.getId());
|
||||||
|
if (contractOutsDO == null) {
|
||||||
|
throw exception(CONTRACT_OUTS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||||
|
updateObj.setUpdater(userName);
|
||||||
|
|
||||||
contractOutsMapper.updateById(updateObj);
|
contractOutsMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user