From 6c3c29f741686fa1b77f1d6adb8832ddbaacbb04 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 ++++--- .../src/main/resources/application-dev.yml | 2 +- 3 files changed, 20 insertions(+), 4 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<>(); diff --git a/renren-admin/src/main/resources/application-dev.yml b/renren-admin/src/main/resources/application-dev.yml index e6182c4..fc12e91 100644 --- a/renren-admin/src/main/resources/application-dev.yml +++ b/renren-admin/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/mt_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true username: root - password: 123456 + password: ztt202812 #达梦8 # driver-class-name: dm.jdbc.driver.DmDriver # url: jdbc:dm://192.168.10.10:5236/renren_security?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true