Yansen 2 år sedan
förälder
incheckning
93d56c1aef

+ 1
- 1
src/main/java/com/yunzhi/inte/mapper/FoodIngredientsMapper.java Visa fil

@@ -21,7 +21,7 @@ public interface FoodIngredientsMapper  extends BaseMapper<FoodIngredients>{
21 21
 
22 22
     List<FoodIngredients> getListByDish(@Param("dishId") Integer dishId);
23 23
 
24
-    int deleteNotExist(@Param("idList") List<Integer> idList);
24
+    int deleteNotExist(@Param("dishId") Integer dishId, @Param("idList") List<Integer> idList);
25 25
 
26 26
     FoodIngredients getByDishAndItem(@Param("dishId") Integer dishId,@Param("itemId") Integer itemId);
27 27
 

+ 1
- 1
src/main/java/com/yunzhi/inte/service/impl/FoodIngredientsServiceImpl.java Visa fil

@@ -50,7 +50,7 @@ public class FoodIngredientsServiceImpl extends BaseServiceImpl<FoodIngredientsM
50 50
             idList.add(-1);
51 51
         }
52 52
         // 删除剩余的
53
-        baseMapper.deleteNotExist(idList);
53
+        baseMapper.deleteNotExist(dishId, idList);
54 54
     }
55 55
 
56 56
     @Override

+ 4
- 1
src/main/resources/mapper/FoodIngredientsMapper.xml Visa fil

@@ -13,7 +13,10 @@
13 13
             s.dish_id = #{dishId}
14 14
     </sql>
15 15
     <delete id="deleteNotExist">
16
-        delete from food_ingredients where id not in
16
+        delete from food_ingredients
17
+        where
18
+            dish_id = #{dishId}
19
+            AND id not in
17 20
         <foreach item="id" collection="idList" separator="," open="(" close=")" index="">
18 21
             #{id}
19 22
         </foreach>