mirror of
https://gitee.com/zhijiantianya/ruoyi-vue-pro.git
synced 2026-10-06 07:22:59 +08:00
[ENHANCE] 商城:SPU 创建补 SKU 属性集合为空的前置校验(前端空规格形态拦截、请求不发)
This commit is contained in:
+2
-5
@@ -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,这里明确拒绝
|
||||
.map(ProductSkuSaveReqVO.Property::getPropertyId)
|
||||
.collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(propertyIds)) {
|
||||
throw exception(SKU_PROPERTIES_EMPTY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user