guang:完成套餐部分
This commit is contained in:
parent
5ce6e3ccc7
commit
78c5b00f5d
@ -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 io.renren.common.annotation.LogOperation;
|
import io.renren.common.annotation.LogOperation;
|
||||||
import io.renren.common.constant.Constant;
|
import io.renren.common.constant.Constant;
|
||||||
import io.renren.common.page.PageData;
|
import io.renren.common.page.PageData;
|
||||||
@ -10,8 +11,11 @@ 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.SetmealDish;
|
||||||
import io.renren.modules.takeout.dto.SetmealDTO;
|
import io.renren.modules.takeout.dto.SetmealDTO;
|
||||||
|
import io.renren.modules.takeout.dto.SetmealDishDTO;
|
||||||
import io.renren.modules.takeout.excel.SetmealExcel;
|
import io.renren.modules.takeout.excel.SetmealExcel;
|
||||||
|
import io.renren.modules.takeout.service.SetmealDishService;
|
||||||
import io.renren.modules.takeout.service.SetmealService;
|
import io.renren.modules.takeout.service.SetmealService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
@ -21,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
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.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
@ -43,7 +48,12 @@ import java.util.Map;
|
|||||||
public class SetmealController {
|
public class SetmealController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SetmealService setmealService;
|
private SetmealService setmealService;
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
@Autowired
|
||||||
|
private SetmealDishService setmealDishService;
|
||||||
|
@Autowired
|
||||||
|
private io.renren.modules.front.service.SetmealDishService setmealDishServiceFront;
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@ApiOperation("分页")
|
@ApiOperation("分页")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ -75,9 +85,29 @@ public class SetmealController {
|
|||||||
public Result save(@RequestBody SetmealDTO dto){
|
public Result save(@RequestBody SetmealDTO dto){
|
||||||
//效验数据
|
//效验数据
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
log.info("dto=={}",dto);
|
||||||
setmealService.save(dto);
|
setmealService.save(dto);
|
||||||
|
//保存套餐菜品信息
|
||||||
|
List<SetmealDishDTO> setmealDishes=dto.getSetmealDishes();
|
||||||
|
log.info("123456");
|
||||||
|
log.info("dishes={}",setmealDishes);
|
||||||
|
for (SetmealDishDTO setmealDishDTO:setmealDishes){
|
||||||
|
log.info("654321");
|
||||||
|
log.info("setmealDish={}",setmealDishDTO);
|
||||||
|
// SetmealDishDTO setmealDishDTO =new SetmealDishDTO();
|
||||||
|
//// BeanUtils.copyProperties(setmealDish, setmealDishDTO);
|
||||||
|
setmealDishDTO.setSetmealId(dto.getId().toString());
|
||||||
|
// setmealDishDTO.setCopies(setmealDish.getCopies());
|
||||||
|
// setmealDishDTO.setDishId(setmealDish.getDishId());
|
||||||
|
// setmealDishDTO.setName(setmealDish.getName());
|
||||||
|
// setmealDishDTO.setPrice(setmealDish.getPrice());
|
||||||
|
log.info("setmealDishDTO=={}",setmealDishDTO);
|
||||||
|
setmealDishService.save(setmealDishDTO);
|
||||||
|
// setmealDish.setSetmealId(dto.getId().toString());
|
||||||
|
}
|
||||||
|
// setmealDishService.insertBatch(setmealDishes);
|
||||||
|
//清除所有的菜品缓存数据
|
||||||
|
redisTemplate.delete("setmeal_*");
|
||||||
return new Result();
|
return new Result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +119,16 @@ public class SetmealController {
|
|||||||
public Result update(@RequestBody SetmealDTO dto){
|
public Result update(@RequestBody SetmealDTO dto){
|
||||||
//效验数据
|
//效验数据
|
||||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
setmealService.update(dto);
|
setmealService.update(dto);
|
||||||
|
LambdaQueryWrapper<SetmealDish> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.in(SetmealDish::getSetmealId,dto.getId());
|
||||||
|
setmealDishServiceFront.remove(wrapper);
|
||||||
|
List<SetmealDishDTO> setmealDishes=dto.getSetmealDishes();
|
||||||
|
for (SetmealDishDTO setmealDishDTO:setmealDishes){
|
||||||
|
setmealDishDTO.setSetmealId(dto.getId().toString());
|
||||||
|
setmealDishService.save(setmealDishDTO);
|
||||||
|
} //清除所有的菜品缓存数据
|
||||||
|
redisTemplate.delete("setmeal_*");
|
||||||
return new Result();
|
return new Result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,10 +140,15 @@ public class SetmealController {
|
|||||||
public Result delete(@RequestBody Long[] ids){
|
public Result delete(@RequestBody Long[] ids){
|
||||||
//效验数据
|
//效验数据
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
|
|
||||||
|
|
||||||
setmealService.delete(ids);
|
setmealService.delete(ids);
|
||||||
|
//清除SetmealDish
|
||||||
|
for (Long id:ids){
|
||||||
|
LambdaQueryWrapper<SetmealDish> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SetmealDish::getSetmealId,id);
|
||||||
|
setmealDishServiceFront.remove(wrapper);
|
||||||
|
}
|
||||||
|
//清除所有的菜品缓存数据
|
||||||
|
redisTemplate.delete("setmeal_*");
|
||||||
return new Result();
|
return new Result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +176,6 @@ public class SetmealController {
|
|||||||
ids.add(value);
|
ids.add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("ids=-={}",ids);
|
|
||||||
setmealService.updateStatus(ids);
|
setmealService.updateStatus(ids);
|
||||||
return new Result();
|
return new Result();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
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.renren.modules.front.bean.Dish;
|
||||||
|
import io.renren.modules.takeout.entity.SetmealDishEntity;
|
||||||
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;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 套餐
|
* 套餐
|
||||||
@ -44,19 +50,25 @@ public class SetmealDTO implements Serializable {
|
|||||||
private String image;
|
private String image;
|
||||||
|
|
||||||
@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;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否删除")
|
@ApiModelProperty(value = "是否删除")
|
||||||
private Integer isDeleted;
|
private Integer isDeleted;
|
||||||
|
|
||||||
|
//菜品的集合
|
||||||
|
private List<SetmealDishDTO> setmealDishes = new ArrayList<>();
|
||||||
|
// private List<SetmealDishEntity> setmealDishEntityList =new ArrayList<>();
|
||||||
}
|
}
|
@ -1,12 +1,17 @@
|
|||||||
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.renren.modules.front.bean.Dish;
|
||||||
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;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 套餐菜品关系
|
* 套餐菜品关系
|
||||||
@ -41,19 +46,24 @@ public class SetmealDishDTO 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;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否删除")
|
@ApiModelProperty(value = "是否删除")
|
||||||
private Integer isDeleted;
|
private Integer isDeleted;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -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;
|
||||||
|
|
||||||
@ -47,18 +49,22 @@ public class SetmealDishEntity {
|
|||||||
/**
|
/**
|
||||||
* 创建人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Long creator;
|
private Long creator;
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date createDate;
|
private Date createDate;
|
||||||
/**
|
/**
|
||||||
* 修改人
|
* 修改人
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Long updater;
|
private Long updater;
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
/**
|
/**
|
||||||
* 是否删除
|
* 是否删除
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -51,18 +53,22 @@ public class SetmealEntity {
|
|||||||
/**
|
/**
|
||||||
* 创建人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Long creator;
|
private Long creator;
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date createDate;
|
private Date createDate;
|
||||||
/**
|
/**
|
||||||
* 修改人
|
* 修改人
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Long updater;
|
private Long updater;
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
/**
|
/**
|
||||||
* 是否删除
|
* 是否删除
|
||||||
|
@ -13,7 +13,5 @@ import java.util.List;
|
|||||||
* @since 1.0.0 2023-06-09
|
* @since 1.0.0 2023-06-09
|
||||||
*/
|
*/
|
||||||
public interface SetmealService extends CrudService<SetmealEntity, SetmealDTO> {
|
public interface SetmealService extends CrudService<SetmealEntity, SetmealDTO> {
|
||||||
|
|
||||||
|
|
||||||
void updateStatus(List<String> ids);
|
void updateStatus(List<String> ids);
|
||||||
}
|
}
|
@ -21,7 +21,6 @@ import java.util.Map;
|
|||||||
* @author zyx
|
* @author zyx
|
||||||
* @since 1.0.0 2023-06-09
|
* @since 1.0.0 2023-06-09
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntity, SetmealDTO> implements SetmealService {
|
public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntity, SetmealDTO> implements SetmealService {
|
||||||
|
|
||||||
@ -37,13 +36,8 @@ public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntit
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(List<String> ids) {
|
public void updateStatus(List<String> ids) {
|
||||||
if (ids == null || ids.isEmpty()) {
|
|
||||||
log.info("ids==null----");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ids.size()>1){
|
if (ids.size()>1){
|
||||||
int index =Integer.parseInt(ids.get(0)) ;
|
int index =Integer.parseInt(ids.get(0)) ;
|
||||||
log.info("index=={}",index);
|
|
||||||
for (int i = 1; i < ids.size(); i++) {
|
for (int i = 1; i < ids.size(); i++) {
|
||||||
Long id =Long.parseLong(ids.get(i)) ;
|
Long id =Long.parseLong(ids.get(i)) ;
|
||||||
SetmealEntity setmeal = this.selectById(id);
|
SetmealEntity setmeal = this.selectById(id);
|
||||||
@ -53,7 +47,6 @@ public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntit
|
|||||||
}else {
|
}else {
|
||||||
Long id =Long.parseLong(ids.get(0)) ;
|
Long id =Long.parseLong(ids.get(0)) ;
|
||||||
SetmealEntity setmeal = this.selectById(id);
|
SetmealEntity setmeal = this.selectById(id);
|
||||||
log.info("SetmealEntity111={}",setmeal);
|
|
||||||
if (setmeal.getStatus().equals(1)){
|
if (setmeal.getStatus().equals(1)){
|
||||||
setmeal.setStatus(0);
|
setmeal.setStatus(0);
|
||||||
this.updateById(setmeal);
|
this.updateById(setmeal);
|
||||||
@ -62,7 +55,6 @@ public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntit
|
|||||||
setmeal.setStatus(1);
|
setmeal.setStatus(1);
|
||||||
this.updateById(setmeal);
|
this.updateById(setmeal);
|
||||||
}
|
}
|
||||||
log.info("SetmealEntity222={}",setmeal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user