mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-02 05:11:59 +08:00
[fix] 优化合同管理功能
This commit is contained in:
parent
5c4b2e1271
commit
c44b48ec3f
@ -51,16 +51,16 @@ public class ContractController {
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除合同")
|
||||
@Parameter(name = "projectId", description = "项目id", required = true)
|
||||
@Parameter(name = "id", description = "项目id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract:delete')")
|
||||
public CommonResult<Boolean> deleteContract(@RequestParam("projectId") Long projectId) {
|
||||
contractService.deleteContract(projectId);
|
||||
public CommonResult<Boolean> deleteContract(@RequestParam("id") Long id) {
|
||||
contractService.deleteContract(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得合同")
|
||||
@Parameter(name = "projectId", description = "项目id", required = true, example = "1024")
|
||||
@Parameter(name = "projectId", description = "项目id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract:query')")
|
||||
public CommonResult<ContractRespVO> getContract(@RequestParam("projectId") Long projectId) {
|
||||
ContractRespVO contractRespVO = contractService.getContract(projectId);
|
||||
@ -88,4 +88,6 @@ public class ContractController {
|
||||
BeanUtils.toBean(list, ContractRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -16,6 +16,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class ContractPageReqVO extends PageParam {
|
||||
|
||||
|
||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long projectId;
|
||||
|
||||
@Schema(description = "合同名称", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
|
@ -5,7 +5,6 @@ import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@ -15,7 +14,6 @@ import com.alibaba.excel.annotation.*;
|
||||
public class ContractRespVO {
|
||||
|
||||
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SJ24001")
|
||||
@ExcelProperty("项目编号")
|
||||
private String code;
|
||||
@ -28,6 +26,14 @@ public class ContractRespVO {
|
||||
@ExcelProperty("项目经理")
|
||||
private String projectManager;
|
||||
|
||||
@Schema(description = "合同提示时间")
|
||||
@ExcelProperty("合同提示时间")
|
||||
private LocalDateTime reminderTime;
|
||||
|
||||
@Schema(description = "暂定结算数")
|
||||
@ExcelProperty("暂定结算数")
|
||||
private BigDecimal provisionalSettlement;
|
||||
|
||||
@Schema(description = "出图公司", requiredMode = Schema.RequiredMode.REQUIRED,example = "***设计院")
|
||||
@ExcelProperty("出图公司")
|
||||
private String drawingCompany;
|
||||
@ -36,13 +42,6 @@ public class ContractRespVO {
|
||||
@ExcelProperty("预计合同金额")
|
||||
private BigDecimal expectedContractAmount;
|
||||
|
||||
@Schema(description = "分包合同商议提示", requiredMode = Schema.RequiredMode.REQUIRED,example = "2024年6月28日")
|
||||
@ExcelProperty("分包合同商议提示")
|
||||
private Date subcontractNegotiationTips;
|
||||
|
||||
@Schema(description = "暂定结算数", requiredMode = Schema.RequiredMode.REQUIRED,example = "68.0000")
|
||||
@ExcelProperty("暂定结算数")
|
||||
private Double ProvisionalSettlement;
|
||||
|
||||
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("合同名称")
|
||||
|
@ -1,5 +1,4 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.contract.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
@ -10,6 +9,12 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class ContractSaveReqVO {
|
||||
|
||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
private Long projectId;
|
||||
|
||||
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "合同名称不能为空")
|
||||
private String name;
|
||||
@ -92,4 +97,19 @@ public class ContractSaveReqVO {
|
||||
@Schema(description = "其他费")
|
||||
private BigDecimal otherFee;
|
||||
|
||||
|
||||
@Schema(description = "创建者")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "创建时间不能为空")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新者")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "更新时间不能为空")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.customerCompany;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
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 cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo.*;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
|
||||
import cn.iocoder.yudao.module.cms.service.customerCompany.CustomerCompanyService;
|
||||
|
||||
@Tag(name = "管理后台 - 客户公司")
|
||||
@RestController
|
||||
@RequestMapping("/cms/customer-company")
|
||||
@Validated
|
||||
public class CustomerCompanyController {
|
||||
|
||||
@Resource
|
||||
private CustomerCompanyService customerCompanyService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建客户公司")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:create')")
|
||||
public CommonResult<Long> createCustomerCompany(@Valid @RequestBody CustomerCompanySaveReqVO createReqVO) {
|
||||
return success(customerCompanyService.createCustomerCompany(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新客户公司")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:update')")
|
||||
public CommonResult<Boolean> updateCustomerCompany(@Valid @RequestBody CustomerCompanySaveReqVO updateReqVO) {
|
||||
customerCompanyService.updateCustomerCompany(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除客户公司")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:delete')")
|
||||
public CommonResult<Boolean> deleteCustomerCompany(@RequestParam("id") Long id) {
|
||||
customerCompanyService.deleteCustomerCompany(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得客户公司")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:query')")
|
||||
public CommonResult<CustomerCompanyRespVO> getCustomerCompany(@RequestParam("id") Long id) {
|
||||
CustomerCompanyDO customerCompany = customerCompanyService.getCustomerCompany(id);
|
||||
return success(BeanUtils.toBean(customerCompany, CustomerCompanyRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客户公司分页")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:query')")
|
||||
public CommonResult<PageResult<CustomerCompanyRespVO>> getCustomerCompanyPage(@Valid CustomerCompanyPageReqVO pageReqVO) {
|
||||
PageResult<CustomerCompanyDO> pageResult = customerCompanyService.getCustomerCompanyPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CustomerCompanyRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得客户公司列表")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:query')")
|
||||
public CommonResult<List<CustomerCompanyRespVO>> getCustomerCompanyList(CustomerCompanyPageReqVO reqVO) {
|
||||
List<CustomerCompanyDO> list = customerCompanyService.getCustomerCompanyList(reqVO);
|
||||
return success(BeanUtils.toBean(list, CustomerCompanyRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出客户公司 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportCustomerCompanyExcel(@Valid CustomerCompanyPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<CustomerCompanyDO> list = customerCompanyService.getCustomerCompanyPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "客户公司.xls", "数据", CustomerCompanyRespVO.class,
|
||||
BeanUtils.toBean(list, CustomerCompanyRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 客户公司分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CustomerCompanyPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "联系人", example = "张三")
|
||||
private String contacts;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "公司名称", example = "电力公司")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "电话")
|
||||
private String phone;
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 客户公司 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CustomerCompanyRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14907")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "联系人", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("联系人")
|
||||
private String contacts;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "电力公司")
|
||||
@ExcelProperty("公司名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "地址")
|
||||
@ExcelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "电话")
|
||||
@ExcelProperty("电话")
|
||||
private String phone;
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 客户公司新增/修改 Request VO")
|
||||
@Data
|
||||
public class CustomerCompanySaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14907")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "联系人", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "联系人不能为空")
|
||||
private String contacts;
|
||||
|
||||
@Schema(description = "公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "电力公司")
|
||||
@NotEmpty(message = "公司名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "电话")
|
||||
private String phone;
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 客户公司 DO
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@TableName("cms_customer_company")
|
||||
@KeySequence("cms_customer_company_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CustomerCompanyDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contacts;
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
}
|
@ -18,6 +18,7 @@ public interface ContractMapper extends BaseMapperX<ContractDO> {
|
||||
default PageResult<ContractDO> selectPage(ContractPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ContractDO>()
|
||||
.likeIfPresent(ContractDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ContractDO::getProjectId, reqVO.getProjectId())
|
||||
.eqIfPresent(ContractDO::getType, reqVO.getType())
|
||||
.eqIfPresent(ContractDO::getProgress, reqVO.getProgress())
|
||||
.betweenIfPresent(ContractDO::getExpectedTime, reqVO.getExpectedTime())
|
||||
@ -45,8 +46,6 @@ public interface ContractMapper extends BaseMapperX<ContractDO> {
|
||||
.eqIfPresent(ContractDO::getOtherFee, reqVO.getOtherFee())
|
||||
|
||||
.orderByDesc(ContractDO::getId)
|
||||
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.dal.mysql.customerCompany;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo.*;
|
||||
|
||||
/**
|
||||
* 客户公司 Mapper
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@Mapper
|
||||
public interface CustomerCompanyMapper extends BaseMapperX<CustomerCompanyDO> {
|
||||
|
||||
default PageResult<CustomerCompanyDO> selectPage(CustomerCompanyPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CustomerCompanyDO>()
|
||||
.likeIfPresent(CustomerCompanyDO::getContacts, reqVO.getContacts())
|
||||
.eqIfPresent(CustomerCompanyDO::getCreateTime, reqVO.getCreateTime())
|
||||
.likeIfPresent(CustomerCompanyDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CustomerCompanyDO::getAddress, reqVO.getAddress())
|
||||
.eqIfPresent(CustomerCompanyDO::getPhone, reqVO.getPhone())
|
||||
.orderByDesc(CustomerCompanyDO::getId));
|
||||
}
|
||||
|
||||
default List<CustomerCompanyDO> selectList(CustomerCompanyPageReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<CustomerCompanyDO>());
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.cms.service.contract;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.contract.ContractMapper;
|
||||
import cn.iocoder.yudao.module.pms.api.ProjectApi;
|
||||
import cn.iocoder.yudao.module.pms.api.dto.project.ProjectDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.dto.project.ProjectRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -25,6 +27,7 @@ import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*;
|
||||
@Validated
|
||||
public class ContractServiceImpl implements ContractService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ContractServiceImpl.class);
|
||||
@Resource
|
||||
private ContractMapper contractMapper;
|
||||
|
||||
@ -64,7 +67,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
|
||||
@Override
|
||||
public ContractRespVO getContract(Long projectId) {
|
||||
ContractDO contractDO = contractMapper.selectById(projectId);
|
||||
ContractDO contractDO = contractMapper.selectOne("project_id",projectId);
|
||||
ContractRespVO contractRespVO = BeanUtils.toBean(contractDO, ContractRespVO.class);
|
||||
|
||||
// 需要联表查询
|
||||
|
@ -1,61 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.service.customerCompany;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo.*;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 客户公司 Service 接口
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
public interface CustomerCompanyService {
|
||||
|
||||
/**
|
||||
* 创建客户公司
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createCustomerCompany(@Valid CustomerCompanySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新客户公司
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateCustomerCompany(@Valid CustomerCompanySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除客户公司
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteCustomerCompany(Long id);
|
||||
|
||||
/**
|
||||
* 获得客户公司
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 客户公司
|
||||
*/
|
||||
CustomerCompanyDO getCustomerCompany(Long id);
|
||||
|
||||
/**
|
||||
* 获得客户公司分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 客户公司分页
|
||||
*/
|
||||
PageResult<CustomerCompanyDO> getCustomerCompanyPage(CustomerCompanyPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得客户公司列表
|
||||
* @param reqVO 查询参数
|
||||
* @return 列表信息
|
||||
*/
|
||||
List<CustomerCompanyDO> getCustomerCompanyList(CustomerCompanyPageReqVO reqVO);
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.service.customerCompany;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo.*;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.customerCompany.CustomerCompanyMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 客户公司 Service 实现类
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CustomerCompanyServiceImpl implements CustomerCompanyService {
|
||||
|
||||
@Resource
|
||||
private CustomerCompanyMapper customerCompanyMapper;
|
||||
|
||||
@Override
|
||||
public Long createCustomerCompany(CustomerCompanySaveReqVO createReqVO) {
|
||||
// 插入
|
||||
CustomerCompanyDO customerCompany = BeanUtils.toBean(createReqVO, CustomerCompanyDO.class);
|
||||
customerCompanyMapper.insert(customerCompany);
|
||||
// 返回
|
||||
return customerCompany.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCustomerCompany(CustomerCompanySaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateCustomerCompanyExists(updateReqVO.getId());
|
||||
// 更新
|
||||
CustomerCompanyDO updateObj = BeanUtils.toBean(updateReqVO, CustomerCompanyDO.class);
|
||||
customerCompanyMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCustomerCompany(Long id) {
|
||||
// 校验存在
|
||||
validateCustomerCompanyExists(id);
|
||||
// 删除
|
||||
customerCompanyMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateCustomerCompanyExists(Long id) {
|
||||
if (customerCompanyMapper.selectById(id) == null) {
|
||||
throw exception(CUSTOMER_COMPANY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomerCompanyDO getCustomerCompany(Long id) {
|
||||
return customerCompanyMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CustomerCompanyDO> getCustomerCompanyPage(CustomerCompanyPageReqVO pageReqVO) {
|
||||
return customerCompanyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomerCompanyDO> getCustomerCompanyList(CustomerCompanyPageReqVO reqVO) {
|
||||
return customerCompanyMapper.selectList(reqVO);
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.cms.dal.mysql.customerCompany.CustomerCompanyMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.cms.service.contact;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.contract.ContractMapper;
|
||||
import cn.iocoder.yudao.module.cms.service.contract.ContractService;
|
||||
import cn.iocoder.yudao.module.cms.service.contract.ContractServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Import(ContractServiceImpl.class)
|
||||
@SpringBootTest(classes = ContractServiceImpl.class)
|
||||
|
||||
public class ContactServiceTest extends BaseDbUnitTest {
|
||||
@Resource
|
||||
private ContractService contractService;
|
||||
|
||||
@Resource
|
||||
private ContractMapper contractMapper;
|
||||
|
||||
|
||||
@Test
|
||||
public void createContact() {
|
||||
}
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
package cn.iocoder.yudao.module.cms.service.customerCompany;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.controller.admin.customerCompany.vo.*;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.customerCompany.CustomerCompanyMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link CustomerCompanyServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@Import(CustomerCompanyServiceImpl.class)
|
||||
public class CustomerCompanyServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private CustomerCompanyServiceImpl customerCompanyService;
|
||||
|
||||
@Resource
|
||||
private CustomerCompanyMapper customerCompanyMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateCustomerCompany_success() {
|
||||
// 准备参数
|
||||
CustomerCompanySaveReqVO createReqVO = randomPojo(CustomerCompanySaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long customerCompanyId = customerCompanyService.createCustomerCompany(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(customerCompanyId);
|
||||
// 校验记录的属性是否正确
|
||||
CustomerCompanyDO customerCompany = customerCompanyMapper.selectById(customerCompanyId);
|
||||
assertPojoEquals(createReqVO, customerCompany, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCustomerCompany_success() {
|
||||
// mock 数据
|
||||
CustomerCompanyDO dbCustomerCompany = randomPojo(CustomerCompanyDO.class);
|
||||
customerCompanyMapper.insert(dbCustomerCompany);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
CustomerCompanySaveReqVO updateReqVO = randomPojo(CustomerCompanySaveReqVO.class, o -> {
|
||||
o.setId(dbCustomerCompany.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
customerCompanyService.updateCustomerCompany(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
CustomerCompanyDO customerCompany = customerCompanyMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, customerCompany);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCustomerCompany_notExists() {
|
||||
// 准备参数
|
||||
CustomerCompanySaveReqVO updateReqVO = randomPojo(CustomerCompanySaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> customerCompanyService.updateCustomerCompany(updateReqVO), CUSTOMER_COMPANY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCustomerCompany_success() {
|
||||
// mock 数据
|
||||
CustomerCompanyDO dbCustomerCompany = randomPojo(CustomerCompanyDO.class);
|
||||
customerCompanyMapper.insert(dbCustomerCompany);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbCustomerCompany.getId();
|
||||
|
||||
// 调用
|
||||
customerCompanyService.deleteCustomerCompany(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(customerCompanyMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCustomerCompany_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> customerCompanyService.deleteCustomerCompany(id), CUSTOMER_COMPANY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetCustomerCompanyPage() {
|
||||
// mock 数据
|
||||
CustomerCompanyDO dbCustomerCompany = randomPojo(CustomerCompanyDO.class, o -> { // 等会查询到
|
||||
o.setContacts(null);
|
||||
o.setCreateTime(null);
|
||||
o.setName(null);
|
||||
o.setAddress(null);
|
||||
o.setPhone(null);
|
||||
});
|
||||
customerCompanyMapper.insert(dbCustomerCompany);
|
||||
// 测试 contacts 不匹配
|
||||
customerCompanyMapper.insert(cloneIgnoreId(dbCustomerCompany, o -> o.setContacts(null)));
|
||||
// 测试 createTime 不匹配
|
||||
customerCompanyMapper.insert(cloneIgnoreId(dbCustomerCompany, o -> o.setCreateTime(null)));
|
||||
// 测试 name 不匹配
|
||||
customerCompanyMapper.insert(cloneIgnoreId(dbCustomerCompany, o -> o.setName(null)));
|
||||
// 测试 address 不匹配
|
||||
customerCompanyMapper.insert(cloneIgnoreId(dbCustomerCompany, o -> o.setAddress(null)));
|
||||
// 测试 phone 不匹配
|
||||
customerCompanyMapper.insert(cloneIgnoreId(dbCustomerCompany, o -> o.setPhone(null)));
|
||||
// 准备参数
|
||||
CustomerCompanyPageReqVO reqVO = new CustomerCompanyPageReqVO();
|
||||
reqVO.setContacts(null);
|
||||
reqVO.setCreateTime(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setAddress(null);
|
||||
reqVO.setPhone(null);
|
||||
|
||||
// 调用
|
||||
PageResult<CustomerCompanyDO> pageResult = customerCompanyService.getCustomerCompanyPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbCustomerCompany, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
<configuration>
|
||||
<!-- 引用 Spring Boot 的 logback 基础配置 -->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
</configuration>
|
@ -0,0 +1,2 @@
|
||||
-- 将该删表 SQL 语句,添加到 yudao-module-cms-biz 模块的 test/resources/sql/clean.sql 文件里
|
||||
DELETE FROM "cms_contract";
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.pms.api;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.api.dto.project.ProjectDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.dto.project.ProjectRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO;
|
||||
|
||||
public interface ProjectApi {
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.pms.api.dto.project;
|
||||
package cn.iocoder.yudao.module.pms.api.project.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.pms.api.dto.project;
|
||||
package cn.iocoder.yudao.module.pms.api.project.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -2,14 +2,19 @@ package cn.iocoder.yudao.module.pms.api.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.pms.api.ProjectApi;
|
||||
import cn.iocoder.yudao.module.pms.api.dto.project.ProjectDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.dto.project.ProjectRespDTO;
|
||||
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.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.mysql.project.ProjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class ProjectImpl implements ProjectApi {
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.pms.dal.mysql.project;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.project.vo.ProjectPageReqVO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
@ -33,7 +32,6 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
|
||||
.selectAll(ProjectDO.class)
|
||||
.selectAs(DeptDO::getName, ProjectDetailDO::getTrackingDepName) // 映射到ProjectDetailDO的trackingDeptName
|
||||
.selectAs(AdminUserDO::getNickname, ProjectDetailDO::getProjectManagerName) // 映射到ProjectDetailDO的projectManagerName
|
||||
.selectAs(CustomerCompanyDO::getName, ProjectDetailDO::getCustomerCompanyName)
|
||||
.likeIfExists(ProjectDO::getName, reqVO.getName())
|
||||
.eqIfExists(ProjectDO::getTrackingCode, reqVO.getTrackingCode())
|
||||
.eqIfExists(ProjectDO::getType, reqVO.getType())
|
||||
@ -41,7 +39,6 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
|
||||
.orderByDesc(ProjectDO::getId)
|
||||
.leftJoin(DeptDO.class, DeptDO::getId, ProjectDO::getTrackingDepId)
|
||||
.leftJoin(AdminUserDO.class, AdminUserDO::getId, ProjectDO::getProjectManagerId)
|
||||
.leftJoin(CustomerCompanyDO.class, CustomerCompanyDO::getId, ProjectDO::getCustomerCompanyId)
|
||||
);
|
||||
}
|
||||
|
||||
@ -50,11 +47,9 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
|
||||
.selectAll(ProjectDO.class)
|
||||
.selectAs(DeptDO::getName, ProjectDetailDO::getTrackingDepName) // 映射到ProjectDetailDO的trackingDeptName
|
||||
.selectAs(AdminUserDO::getNickname, ProjectDetailDO::getProjectManagerName) // 映射到ProjectDetailDO的projectManagerName
|
||||
.selectAs(CustomerCompanyDO::getName, ProjectDetailDO::getCustomerCompanyName)
|
||||
.eqIfExists(ProjectDO::getId, id)
|
||||
.leftJoin(DeptDO.class, DeptDO::getId, ProjectDO::getTrackingDepId)
|
||||
.leftJoin(AdminUserDO.class, AdminUserDO::getId, ProjectDO::getProjectManagerId)
|
||||
.leftJoin(CustomerCompanyDO.class, CustomerCompanyDO::getId, ProjectDO::getCustomerCompanyId)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -133,6 +133,7 @@
|
||||
<artifactId>yudao-spring-boot-starter-protection</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.server;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@ -12,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
|
||||
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package}
|
||||
@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"})
|
||||
public class YudaoServerApplication {
|
||||
|
Loading…
x
Reference in New Issue
Block a user