From 5ce6e3ccc7c269bb7cbc9b86277aa340096beb7f Mon Sep 17 00:00:00 2001 From: mlf9527 <2192316287@qq.com> Date: Tue, 20 Jun 2023 14:03:34 +0800 Subject: [PATCH] =?UTF-8?q?6/20=20=E5=AE=8C=E5=96=84=E4=BA=86=E8=8F=9C?= =?UTF-8?q?=E5=93=81=E5=88=A0=E9=99=A4=E6=97=B6=E5=AF=B9=E5=A5=97=E9=A4=90?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../takeout/controller/DishController.java | 15 +++++++++++++++ .../takeout/controller/SetmealController.java | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java b/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java index 0fc8b9e..8a0e6a5 100644 --- a/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java +++ b/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java @@ -1,5 +1,6 @@ package io.renren.modules.takeout.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import io.renren.common.annotation.LogOperation; import io.renren.common.constant.Constant; @@ -13,7 +14,11 @@ import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; import io.renren.modules.front.bean.Category; import io.renren.modules.front.bean.DishFlavor; +import io.renren.modules.front.bean.Setmeal; +import io.renren.modules.front.bean.SetmealDish; import io.renren.modules.front.service.CategoryService; +import io.renren.modules.front.service.SetmealDishService; +import io.renren.modules.front.service.SetmealService; import io.renren.modules.takeout.dto.DishDTO; import io.renren.modules.takeout.dto.DishFlavorDTO; import io.renren.modules.takeout.entity.DishEntity; @@ -52,6 +57,8 @@ public class DishController { @Autowired private io.renren.modules.front.service.DishFlavorService dishFlavorServiceFront; + @Autowired + private SetmealDishService setmealDishService; @Autowired private CategoryService categoryService; @@ -188,6 +195,14 @@ public class DishController { public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); + for(Long id:ids){ + LambdaQueryWrapper wrapper=new LambdaQueryWrapper<>(); + wrapper.eq(SetmealDish::getDishId,id); + if(setmealDishService.list(wrapper)!=null) { + return new Result().error("存在套餐内含有该菜品"); + } + + } dishService.delete(ids); //清除每个菜品的所有口味信息 diff --git a/renren-admin/src/main/java/io/renren/modules/takeout/controller/SetmealController.java b/renren-admin/src/main/java/io/renren/modules/takeout/controller/SetmealController.java index 196d32f..196754d 100644 --- a/renren-admin/src/main/java/io/renren/modules/takeout/controller/SetmealController.java +++ b/renren-admin/src/main/java/io/renren/modules/takeout/controller/SetmealController.java @@ -104,6 +104,7 @@ public class SetmealController { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); + setmealService.delete(ids); return new Result(); @@ -120,9 +121,9 @@ public class SetmealController { } @PutMapping("updateStatus") - @ApiOperation("更新套餐状态") - @LogOperation("更新套餐状态") - @RequiresPermissions("takeout:setmeal:updateStatus") +// @ApiOperation("更新套餐状态") +// @LogOperation("更新套餐状态") +// @RequiresPermissions("takeout:setmeal:updateStatus") @CacheEvict(value = "setmealCache", allEntries = true) public Result updateStatus(@RequestParam Map params) { List ids=new ArrayList<>();