Browse Source

批量更新商品sku时添加对pid的限制

macro 1 year ago
parent
commit
0387c981d7

+ 5 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/PmsSkuStockServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 商品SKU库存管理Service实现类
@@ -34,6 +35,9 @@ public class PmsSkuStockServiceImpl implements PmsSkuStockService {
 
     @Override
     public int update(Long pid, List<PmsSkuStock> skuStockList) {
-        return skuStockDao.replaceList(skuStockList);
+        List<PmsSkuStock> filterSkuList = skuStockList.stream()
+                .filter(item -> pid.equals(item.getProductId()))
+                .collect(Collectors.toList());
+        return skuStockDao.replaceList(filterSkuList);
     }
 }