Merge remote-tracking branch 'origin/master'

This commit is contained in:
飞光!飞光! 2023-06-19 19:00:42 +08:00
commit d2f1d687c3
3 changed files with 44 additions and 13 deletions

View File

@ -1,5 +1,6 @@
package io.renren.modules.takeout.controller; package io.renren.modules.takeout.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.renren.common.annotation.LogOperation; import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant; import io.renren.common.constant.Constant;
@ -11,16 +12,14 @@ import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup; import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.front.bean.Category; import io.renren.modules.front.bean.Dish;
import io.renren.modules.front.utils.R; import io.renren.modules.front.bean.Setmeal;
import io.renren.modules.front.service.DishService;
import io.renren.modules.front.service.SetmealService;
import io.renren.modules.takeout.dto.CategoryDTO; import io.renren.modules.takeout.dto.CategoryDTO;
import io.renren.modules.takeout.entity.CategoryEntity;
import io.renren.modules.takeout.excel.CategoryExcel; import io.renren.modules.takeout.excel.CategoryExcel;
import io.renren.modules.takeout.service.CategoryService; import io.renren.modules.takeout.service.CategoryService;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -43,6 +42,10 @@ import java.util.Map;
public class CategoryController { public class CategoryController {
@Autowired @Autowired
private CategoryService categoryService; private CategoryService categoryService;
@Autowired
private DishService dishService;
@Autowired
private SetmealService setmealService;
@GetMapping("list") @GetMapping("list")
public Result<List<CategoryDTO>> list(@RequestParam Map<String, Object> params){ public Result<List<CategoryDTO>> list(@RequestParam Map<String, Object> params){
@ -87,6 +90,7 @@ public class CategoryController {
return new Result(); return new Result();
} }
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@ -107,7 +111,22 @@ public class CategoryController {
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
for (Long id : ids) {
CategoryDTO categoryDTO=categoryService.get(id);
if(categoryDTO.getType()==1){
LambdaQueryWrapper<Dish> wrapper=new LambdaQueryWrapper<>();
wrapper.eq(Dish::getCategoryId,id);
if (!dishService.list(wrapper).isEmpty()) {
return new Result().error("存在分类含有菜品或套餐!");
}
}else {
LambdaQueryWrapper<Setmeal> wrapper=new LambdaQueryWrapper<>();
wrapper.eq(Setmeal::getCategoryId,id);
if(!setmealService.list(wrapper).isEmpty()){
return new Result().error("存在分类含有菜品或套餐!");
}
}
}
categoryService.delete(ids); categoryService.delete(ids);
return new Result(); return new Result();

View File

@ -1,5 +1,7 @@
package io.renren.modules.takeout.dto; package io.renren.modules.takeout.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -32,16 +34,19 @@ public class CategoryDTO implements Serializable {
private Integer sort; private Integer sort;
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
@TableField(fill = FieldFill.INSERT)
private Long creator; private Long creator;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createDate; private Date createDate;
@ApiModelProperty(value = "修改人") @ApiModelProperty(value = "修改人")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater; private Long updater;
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate; private Date updateDate;
} }

View File

@ -1,5 +1,7 @@
package io.renren.modules.takeout.entity; package io.renren.modules.takeout.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@ -34,17 +36,22 @@ public class CategoryEntity {
/** /**
* 创建人 * 创建人
*/ */
private Long creator; @TableField(fill = FieldFill.INSERT)
private Long creator;
/** /**
* 创建时间 * 创建时间
*/ */
private Date createDate; @TableField(fill = FieldFill.INSERT)
private Date createDate;
/** /**
* 修改人 * 修改人
*/ */
private Long updater; @TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/** /**
* 更新时间 * 更新时间
*/ */
private Date updateDate; @TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
} }