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

This commit is contained in:
YunaiV
2026-09-26 10:43:34 +08:00
parent ddbfd10161
commit 79ef2aba35
@@ -104,12 +104,9 @@ public class ProductSkuServiceImpl implements ProductSkuService {
// 1、校验属性项存在
Set<Long> propertyIds = skus.stream().filter(p -> p.getProperties() != null)
// 遍历多个 Property 属性
.flatMap(p -> p.getProperties().stream())
// 将每个 Property 转换成对应的 propertyId,最后形成集合
.map(ProductSkuSaveReqVO.Property::getPropertyId)
.collect(Collectors.toSet());
// 多规格下,属性组合不能为空:空集合会让后续按 id 批量查询生成非法 SQL(IN())而 500,这里明确拒绝
if (CollUtil.isEmpty(propertyIds)) {
throw exception(SKU_PROPERTIES_EMPTY);
}