x1ongzhu преди 6 години
родител
ревизия
89ebe3c850

+ 1 - 1
src/main/java/com/izouma/walkchina/repo/ProductSpecRepository.java

@@ -8,5 +8,5 @@ import java.util.List;
 
 public interface ProductSpecRepository extends JpaRepository<ProductSpec, Long> {
     @Transactional
-    void deleteAllByIdNotIn(List<Long> idList);
+    void deleteAllByProductIdAndIdNotIn(Long productId, List<Long> idList);
 }

+ 1 - 1
src/main/java/com/izouma/walkchina/service/ProductService.java

@@ -45,7 +45,7 @@ public class ProductService {
                                        .filter(productSpec -> productSpec.getId() != null)
                                        .map(ProductSpec::getId)
                                        .collect(Collectors.toList());
-            productSpecRepository.deleteAllByIdNotIn(idList);
+            productSpecRepository.deleteAllByProductIdAndIdNotIn(product.getId(), idList);
 
             for (ProductSpec spec : product.getSpecs()) {
                 spec.setProductId(product.getId());