商品列表v2改为post

统计处理空值
绑定相同耗材 提示
This commit is contained in:
wangw 2024-10-08 16:14:09 +08:00
parent e4a03e583b
commit 12cc56aada
4 changed files with 25 additions and 19 deletions

View File

@ -66,9 +66,8 @@ public class TbProskuConController {
tbProskuConService.upV2(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
} catch (BadRequestException be) {
throw new Exception(be.getMessage());
throw new BadRequestException(be.getMessage());
}catch (Exception e){
e.printStackTrace();
throw new Exception(e.getMessage());
}
}

View File

@ -198,29 +198,28 @@ public class TbProskuConServiceImpl implements TbProskuConService {
}
TbProductSku sku = null;
if (resource.getProductSkuId() != 0) {
sku = tbProductSkuRepository.findById(resource.getProductSkuId()).orElseGet(TbProductSku::new);
sku = tbProductSkuRepository.findById(resource.getProductSkuId()).orElseGet(TbProductSku::new);
if (ObjectUtil.isNull(sku) || ObjectUtil.isNull(sku.getId())) {
throw new BadRequestException("规格信息不存在");
}
}
TbProskuCon tbConsInfo1 = new TbProskuCon();
if (resource.getId() == null) {
int count = tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConInfoId(), resource.getProductSkuId(), resource.getShopId(), resource.getProductId());
if (count <= 0) {
BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
} else {
StringBuilder strResult = new StringBuilder(product.getName());
if (sku != null) {
strResult.append(" 规格" + sku.getSpecSnap());
}
strResult.append("与耗材 " + tbConsInfo.getConName() + " 的对应关系已存在");
throw new BadRequestException(product.getName().concat("对应的").concat(Objects.nonNull(sku.getSpecSnap())?sku.getSpecSnap():"").concat("规格已存在"));
}
}else {
BeanUtil.copyProperties(resource,tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
int count = tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConInfoId(), resource.getProductSkuId(), resource.getShopId(), resource.getProductId());
if (count <= 0) {
BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
} else {
StringBuilder strResult = new StringBuilder(product.getName());
if (sku != null) {
strResult.append(" 规格" + sku.getSpecSnap());
}
strResult.append("与耗材 " + tbConsInfo.getConName() + " 的对应关系已存在");
throw new BadRequestException(strResult.toString());
}
BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
}
if (!CollectionUtils.isEmpty(newCons)) {
tbProskuConRepository.saveAll(newCons);

View File

@ -35,7 +35,7 @@ public class TbProductController {
return new ResponseEntity<>(tbProductService.queryAll(criteria, false),HttpStatus.OK);
}
@GetMapping("/list/v2")
@PostMapping("/list/v2")
@ApiOperation("查询商品列表 新")
public ResponseEntity<Object> queryTbProductV2(TbProductQueryV2Criteria criteria, Pageable pageable){
return new ResponseEntity<>(tbProductService.queryAllV2(criteria,pageable),HttpStatus.OK);

View File

@ -2,6 +2,7 @@ package cn.ysk.cashier.dto.product;
import cn.ysk.cashier.dto.BaseQueryDto;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
/**
* @website https://eladmin.vip
@ -20,4 +21,11 @@ public class TbProductStockCountQueryCriteria extends BaseQueryDto {
private Integer page = 0;
private Integer size = 10;
public String getProductName() {
if(StringUtils.isNotBlank(productName)){
return productName;
}
return null;
}
}