main
kkk-ops 10 hours ago
parent afd95d255a
commit 8f08766aaa

@ -54,11 +54,11 @@ public class ErpProductController {
ErpProductPageReqVO productPageReqVO = new ErpProductPageReqVO();
productPageReqVO.setName(createReqVO.getName());
if (!productMapper.selectProductExist(productPageReqVO).getList().isEmpty()) {
return error(400,"名称不能重复");
return error(400,"名称+规格不能重复");
}
productPageReqVO = new ErpProductPageReqVO();
productPageReqVO.setCode(createReqVO.getBarCode());
if (!productMapper.selectProductExist(productPageReqVO).getList().isEmpty()) {
if (!productMapper.selectProductCodeExist(productPageReqVO).getList().isEmpty()) {
return error(400,"编码不能重复");
}
return success(productService.createProduct(createReqVO));

@ -27,4 +27,7 @@ public class ErpProductPageReqVO extends PageParam {
@Schema(description = "产品编号", example = "11161")
private String code;
@Schema(description = "产品规格", example = "红色")
private String standard;
}

@ -29,13 +29,20 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
.orderByDesc(ErpProductDO::getId));
}
default PageResult<ErpProductDO> selectProductExist(ErpProductPageReqVO reqVO) {
default PageResult<ErpProductDO> selectProductCodeExist(ErpProductPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>()
.eqIfPresent(ErpProductDO::getName, reqVO.getName())
.eqIfPresent(ErpProductDO::getBarCode, reqVO.getCode())
.orderByAsc(ErpProductDO::getId));
}
default PageResult<ErpProductDO> selectProductExist(ErpProductPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>()
.eqIfPresent(ErpProductDO::getName, reqVO.getName())
.eqIfPresent(ErpProductDO::getStandard, reqVO.getStandard())
.orderByAsc(ErpProductDO::getId));
}
default Long selectCountByCategoryId(Long categoryId) {
return selectCount(ErpProductDO::getCategoryId, categoryId);
}

Loading…
Cancel
Save