|
@@ -316,8 +316,12 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
productInfoDto.setCode(CodeEnum.PRODUCT.getCode());
|
|
|
// 排除名称重复
|
|
|
this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), "产品名称重复");
|
|
|
- // 排除自定义编码重复
|
|
|
- this.nameDuplication(ProductInfo::getCustomCode, productInfoDto.getCustomCode(), "产品自定义编码重复");
|
|
|
+ // 排除不为空的自定义编码重复
|
|
|
+ long count = this.count(q -> q.eq(ProductInfo::getCustomCode, productInfoDto.getCustomCode()).ne(ProductInfo::getCustomCode,""));
|
|
|
+ if (count != 0) {
|
|
|
+ throw new ServiceException("产品自定义编码重复");
|
|
|
+ }
|
|
|
+
|
|
|
this.save(productInfoDto);
|
|
|
ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
}
|
|
@@ -472,8 +476,12 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
productInfoDto.setCode(null);
|
|
|
// 排除名称重复
|
|
|
this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), productInfoDto.getId(), "产品名称重复");
|
|
|
- // 排除自定义编码重复
|
|
|
- this.nameDuplication(ProductInfo::getCustomCode, productInfoDto.getCustomCode(), productInfoDto.getId(), "产品自定义编码重复");
|
|
|
+ // 排除不为空的自定义编码重复
|
|
|
+ long count = this.count(q -> q.ne(ProductInfo::getId,productInfoDto.getId())
|
|
|
+ .eq(ProductInfo::getCustomCode, productInfoDto.getCustomCode()).ne(ProductInfo::getCustomCode,""));
|
|
|
+ if (count != 0) {
|
|
|
+ throw new ServiceException("产品自定义编码重复");
|
|
|
+ }
|
|
|
this.updateById(productInfoDto);
|
|
|
ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
}
|