feat(customer): 完善客户管理功能
This commit is contained in:
parent
4e3f106563
commit
309e87be7e
@ -67,4 +67,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode PROC_CODE_DUPLICATE = new ErrorCode(1_001_023, "工序编码不能重复");
|
||||
ErrorCode PROC_LINE_CODE_DUPLICATE = new ErrorCode(1_001_023, "产线编码不能重复");
|
||||
|
||||
ErrorCode CUSTOMER_CODE_DUPLICATE = new ErrorCode(1_001_024, "客户编码不能重复");
|
||||
ErrorCode CUSTOMER_NAME_DUPLICATE = new ErrorCode(1_001_025, "客户名称不能重复");
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public class CustomerRespVO {
|
||||
|
||||
@Schema(description = "启用状态(1:启用2:未启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty(value = "启用状态(1:启用2:未启用)", converter = DictConvert.class)
|
||||
@DictFormat("system_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private String enabledStatus;
|
||||
@DictFormat("system_status")
|
||||
private Integer enabledStatus;
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.customer;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.sun.xml.bind.v2.TODO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 客户主数据 DO
|
||||
@ -122,6 +122,6 @@ public class CustomerDO extends BaseDO {
|
||||
*
|
||||
* 枚举 {@link TODO system_status 对应的类}
|
||||
*/
|
||||
private String enabledStatus;
|
||||
private Integer enabledStatus;
|
||||
|
||||
}
|
||||
@ -1,13 +1,11 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.customer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.customer.vo.CustomerPageReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.customer.CustomerDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.customer.vo.*;
|
||||
|
||||
/**
|
||||
* 客户主数据 Mapper
|
||||
@ -19,11 +17,19 @@ public interface CustomerMapper extends BaseMapperX<CustomerDO> {
|
||||
|
||||
default PageResult<CustomerDO> selectPage(CustomerPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CustomerDO>()
|
||||
.eqIfPresent(CustomerDO::getCustNo, reqVO.getCustNo())
|
||||
.likeIfPresent(CustomerDO::getCustNo, reqVO.getCustNo())
|
||||
.likeIfPresent(CustomerDO::getCustName, reqVO.getCustName())
|
||||
.likeIfPresent(CustomerDO::getCustSimName, reqVO.getCustSimName())
|
||||
.eqIfPresent(CustomerDO::getEnabledStatus, reqVO.getEnabledStatus())
|
||||
.orderByDesc(CustomerDO::getId));
|
||||
}
|
||||
|
||||
default CustomerDO selectByCustNo(String custNo) {
|
||||
return selectOne(CustomerDO::getCustNo, custNo);
|
||||
}
|
||||
|
||||
default CustomerDO selectByCustName(String custName) {
|
||||
return selectOne(CustomerDO::getCustName, custName);
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,6 +11,10 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.ningxia.yunxi.chemmes.module.biz.enums.ErrorCodeConstants.CUSTOMER_CODE_DUPLICATE;
|
||||
import static com.ningxia.yunxi.chemmes.module.biz.enums.ErrorCodeConstants.CUSTOMER_NAME_DUPLICATE;
|
||||
|
||||
/**
|
||||
* 客户主数据 Service 实现类
|
||||
*
|
||||
@ -25,6 +29,8 @@ public class CustomerServiceImpl implements CustomerService {
|
||||
|
||||
@Override
|
||||
public Integer createCustomer(CustomerSaveReqVO createReqVO) {
|
||||
validateCustomerCodeUnique(null, createReqVO.getCustNo());
|
||||
validateCustomerNameUnique(null, createReqVO.getCustName());
|
||||
// 插入
|
||||
CustomerDO customer = BeanUtils.toBean(createReqVO, CustomerDO.class);
|
||||
customerMapper.insert(customer);
|
||||
@ -36,11 +42,15 @@ public class CustomerServiceImpl implements CustomerService {
|
||||
public void updateCustomer(CustomerSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateCustomerExists(updateReqVO.getId());
|
||||
validateCustomerCodeUnique(updateReqVO.getId(), updateReqVO.getCustNo());
|
||||
validateCustomerNameUnique(updateReqVO.getId(), updateReqVO.getCustName());
|
||||
// 更新
|
||||
CustomerDO updateObj = BeanUtils.toBean(updateReqVO, CustomerDO.class);
|
||||
customerMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteCustomer(Integer id) {
|
||||
// 校验存在
|
||||
@ -51,7 +61,36 @@ public class CustomerServiceImpl implements CustomerService {
|
||||
|
||||
private void validateCustomerExists(Integer id) {
|
||||
if (customerMapper.selectById(id) == null) {
|
||||
// throw exception(CUSTOMER_NOT_EXISTS);
|
||||
throw exception("数据不存在");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCustomerCodeUnique(Integer id, String custNo) {
|
||||
CustomerDO customer = customerMapper.selectByCustNo(custNo);
|
||||
if (customer == null) {
|
||||
return;
|
||||
}
|
||||
if (id == null) {
|
||||
throw exception(CUSTOMER_CODE_DUPLICATE);
|
||||
}
|
||||
if (!customer.getId().equals(id)) {
|
||||
throw exception(CUSTOMER_CODE_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCustomerNameUnique(Integer id, String custName) {
|
||||
if (custName == null || custName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
CustomerDO customer = customerMapper.selectByCustName(custName);
|
||||
if (customer == null) {
|
||||
return;
|
||||
}
|
||||
if (id == null) {
|
||||
throw exception(CUSTOMER_NAME_DUPLICATE);
|
||||
}
|
||||
if (!customer.getId().equals(id)) {
|
||||
throw exception(CUSTOMER_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ public class ProLineServiceImpl implements ProLineService {
|
||||
|
||||
private void validateProLineExists(Integer id) {
|
||||
if (proLineMapper.selectById(id) == null) {
|
||||
// throw exception(PRO_LINE_NOT_EXISTS);
|
||||
throw exception("数据不存在");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -99,6 +99,11 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="联系人1" align="center" prop="contact1" />
|
||||
<el-table-column label="联系电话1" align="center" prop="conPhone1" />
|
||||
<el-table-column label="状态" align="center" prop="enabledStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_STATUS" :value="scope.row.enabledStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user