fix:修改模具和模具类型的编码为唯一

plp
86158 20 hours ago
parent 6859b3d674
commit c7ef7a4e97

@ -170,6 +170,12 @@ public interface ErrorCodeConstants {
ErrorCode MOLD_NOT_EXISTS = new ErrorCode(1_111_002, "模具不存在");
ErrorCode MOLD_BRAND_PRODUCT_NOT_EXISTS = new ErrorCode(1_111_003, "模具产品不存在");
ErrorCode MOLD_BRAND_PRODUCT_EXISTS = new ErrorCode(1_111_004, "模具产品已存在");
ErrorCode MOLD_CODE_DUPLICATE = new ErrorCode(1_003_000_004, "编码已存在");
ErrorCode MOLD_CODE_EMPTY = new ErrorCode(1_003_000_005, "模具编码不能为空");
ErrorCode MOLD_BRAND_CODE_DUPLICATE = new ErrorCode(1_003_000_006, "模具品牌编码已存在");
ErrorCode MOLD_BRAND_CODE_EMPTY = new ErrorCode(1_003_000_007, "模具品牌编码不能为空");
ErrorCode AUTOCODE_RECORD_NOT_EXISTS = new ErrorCode(1_111_003, "编码生成记录不存在");
@ -178,4 +184,5 @@ public interface ErrorCodeConstants {
ErrorCode AUTOCODE_GEN_NOT_UNIQUE = new ErrorCode(1_111_006, "编码已存在");
ErrorCode PRODUCT_REFERENCES_EXIST = new ErrorCode(1_003_000_000, "存在产品已被引用,请先删除引用。");
}

@ -133,8 +133,8 @@ public class MoldBrandController {
@PostMapping("/mold/create")
@Operation(summary = "创建模具")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:create')")
public CommonResult<Long> createMold(@Valid @RequestBody MoldDO mold) {
return success(moldBrandService.createMold(mold));
public CommonResult<Long> createMold(@Valid @RequestBody MoldSaveReqVO createReqVO) {
return success(moldBrandService.createMold(createReqVO));
}
@PutMapping("/mold/update")

@ -94,7 +94,7 @@ public interface MoldBrandService {
* @param mold
* @return
*/
Long createMold(@Valid MoldDO mold);
Long createMold(@Valid MoldSaveReqVO createReqVO);
/**
*

@ -1,10 +1,13 @@
package cn.iocoder.yudao.module.erp.service.mold;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.common.controller.admin.mold.vo.*;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldBrandProductDO;
@ -21,6 +24,7 @@ import cn.iocoder.yudao.module.common.dal.mysql.moldrepair.MoldRepairLineMapper;
import cn.iocoder.yudao.module.common.dal.mysql.moldrepair.MoldRepairMapper;
import cn.iocoder.yudao.module.common.dal.mysql.moldticketresults.MoldTicketResultsMapper;
import cn.iocoder.yudao.module.common.controller.admin.moldticketmanagement.enums.MoldPlanTypeEnum;
import cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
@ -65,6 +69,17 @@ public class MoldBrandServiceImpl implements MoldBrandService {
@Override
public Long createMoldBrand(MoldBrandSaveReqVO createReqVO) {
// 插入
// MoldBrandDO moldBrand = BeanUtils.toBean(createReqVO, MoldBrandDO.class);
String Code = createReqVO.getCode();
if (StrUtil.isBlank(Code)) {
throw new ServiceException(ErrorCodeConstants.MOLD_BRAND_CODE_EMPTY);
}
boolean exists = moldBrandMapper.exists(
new LambdaQueryWrapperX<MoldBrandDO>().eq(MoldBrandDO::getCode, Code)
);
if (exists) {
throw new ServiceException(ErrorCodeConstants.MOLD_BRAND_CODE_DUPLICATE);
}
MoldBrandDO moldBrand = BeanUtils.toBean(createReqVO, MoldBrandDO.class);
moldBrandMapper.insert(moldBrand);
// 返回
@ -158,7 +173,18 @@ public class MoldBrandServiceImpl implements MoldBrandService {
});
}
@Override
public Long createMold(MoldDO mold) {
public Long createMold(MoldSaveReqVO createReqVO) {
String Code = createReqVO.getCode();
if (StrUtil.isBlank(Code)) {
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_EMPTY);
}
boolean exists = moldMapper.exists(
new LambdaQueryWrapperX<MoldDO>().eq(MoldDO::getCode, Code)
);
if (exists) {
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_DUPLICATE);
}
MoldDO mold = BeanUtils.toBean(createReqVO, MoldDO.class);
moldMapper.insert(mold);
return mold.getId();
}

@ -1,12 +1,16 @@
package cn.iocoder.yudao.module.erp.service.mold;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO;
import cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
@ -41,6 +45,17 @@ public class MoldServiceImpl implements MoldService {
@Override
public Long createMold(MoldSaveReqVO createReqVO) {
// 插入
// MoldDO mold = BeanUtils.toBean(createReqVO, MoldDO.class);
String Code = createReqVO.getCode();
if (StrUtil.isBlank(Code)) {
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_EMPTY);
}
boolean exists = moldMapper.exists(
new LambdaQueryWrapperX<MoldDO>().eq(MoldDO::getCode, Code)
);
if (exists) {
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_DUPLICATE);
}
MoldDO mold = BeanUtils.toBean(createReqVO, MoldDO.class);
moldMapper.insert(mold);
// 返回

Loading…
Cancel
Save