Commit 79ef2aba355196060ed87a7307b20aac19d12b5e

Authored by YunaiV
1 parent ddbfd101

[ENHANCE] 商城:SPU 创建补 SKU 属性集合为空的前置校验(前端空规格形态拦截、请求不发)

yudao-module-mall/yudao-module-product/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
... ... @@ -104,12 +104,9 @@ public class ProductSkuServiceImpl implements ProductSkuService {
104 104  
105 105 // 1、校验属性项存在
106 106 Set<Long> propertyIds = skus.stream().filter(p -> p.getProperties() != null)
107   - // 遍历多个 Property 属性
108 107 .flatMap(p -> p.getProperties().stream())
109   - // 将每个 Property 转换成对应的 propertyId,最后形成集合
110   - .map(ProductSkuSaveReqVO.Property::getPropertyId)
111   - .collect(Collectors.toSet());
112   - // 多规格下,属性组合不能为空:空集合会让后续按 id 批量查询生成非法 SQL(IN())而 500,这里明确拒绝
  108 + .map(ProductSkuSaveReqVO.Property::getPropertyId)
  109 + .collect(Collectors.toSet());
113 110 if (CollUtil.isEmpty(propertyIds)) {
114 111 throw exception(SKU_PROPERTIES_EMPTY);
115 112 }
... ...