6/20 完善了菜品删除时对套餐的处理

This commit is contained in:
mlf9527 2023-06-20 14:03:34 +08:00
parent a7257498f4
commit 6c3c29f741
3 changed files with 20 additions and 4 deletions

View File

@ -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<SetmealDish> wrapper=new LambdaQueryWrapper<>();
wrapper.eq(SetmealDish::getDishId,id);
if(setmealDishService.list(wrapper)!=null) {
return new Result().error("存在套餐内含有该菜品");
}
}
dishService.delete(ids);
//清除每个菜品的所有口味信息

View File

@ -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<String, String> params) {
List<String> ids=new ArrayList<>();

View File

@ -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