新增菜谱
This commit is contained in:
parent
e2e0d6f41e
commit
2a74f41713
|
|
@ -2,6 +2,8 @@ package com.bonus.canteen.core.cook.controller;
|
|||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
//import com.bonus.canteen.core.cook.common.annotation.PreventRepeatSubmit;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -70,6 +72,12 @@ public class CookRecipeController extends BaseController {
|
|||
//@RequiresPermissions("cook:recipe:query")
|
||||
@GetMapping(value = "/{recipeId}")
|
||||
public AjaxResult getInfo(@PathVariable("recipeId") Long recipeId) {
|
||||
// 构造菜谱之菜品详情VO
|
||||
|
||||
// 狗仔菜谱之执行计划VO
|
||||
|
||||
// 狗仔菜谱VO
|
||||
|
||||
return success(cookRecipeService.selectCookRecipeByRecipeId(recipeId));
|
||||
}
|
||||
|
||||
|
|
@ -81,9 +89,9 @@ public class CookRecipeController extends BaseController {
|
|||
//@RequiresPermissions("cook:recipe:add")
|
||||
@SysLog(title = "菜品计划信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增菜品计划信息")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CookRecipe cookRecipe) {
|
||||
public AjaxResult add(@RequestBody CookRecipeDTO cookRecipeDTO) {
|
||||
try {
|
||||
return toAjax(cookRecipeService.insertCookRecipe(cookRecipe));
|
||||
return toAjax(cookRecipeService.insertCookRecipe(cookRecipeDTO));
|
||||
} catch (Exception e) {
|
||||
return error(e.getMessage());
|
||||
}
|
||||
|
|
@ -99,6 +107,11 @@ public class CookRecipeController extends BaseController {
|
|||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody CookRecipe cookRecipe) {
|
||||
try {
|
||||
//TODO 删除菜谱之菜品详情
|
||||
//TODO 删除菜谱之执行计划
|
||||
|
||||
//TODO 新增菜谱之执行计划
|
||||
//TODO 新增菜谱之菜品详情
|
||||
return toAjax(cookRecipeService.updateCookRecipe(cookRecipe));
|
||||
} catch (Exception e) {
|
||||
return error(e.getMessage());
|
||||
|
|
@ -114,6 +127,8 @@ public class CookRecipeController extends BaseController {
|
|||
@SysLog(title = "菜品计划信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品计划信息")
|
||||
@PostMapping("/del/{recipeIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] recipeIds) {
|
||||
//TODO 删除菜谱之菜品详情
|
||||
//TODO 删除菜谱之执行计划
|
||||
return toAjax(cookRecipeService.deleteCookRecipeByRecipeIds(recipeIds));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
package com.bonus.canteen.core.cook.dto;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜品计划信息对象 cook_recipe
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-05-25
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class CookRecipeDTO extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 菜谱id */
|
||||
private Long recipeId;
|
||||
|
||||
/** 菜谱名称 */
|
||||
@Excel(name = "菜谱名称")
|
||||
@ApiModelProperty(value = "菜谱名称")
|
||||
private String recipeName;
|
||||
|
||||
/** 菜谱类型(1默认,2按天,3按周,4按月) */
|
||||
@Excel(name = "菜谱类型(1默认,2按天,3按周,4按月)")
|
||||
@ApiModelProperty(value = "菜谱类型(1默认,2按天,3按周,4按月)")
|
||||
private Long recipeType;
|
||||
|
||||
/** 档口id */
|
||||
@Excel(name = "档口id")
|
||||
@ApiModelProperty(value = "档口id")
|
||||
private Long stallId;
|
||||
|
||||
/** 食堂id */
|
||||
@Excel(name = "食堂id")
|
||||
@ApiModelProperty(value = "食堂id")
|
||||
private Long canteenId;
|
||||
|
||||
/** 菜品计划id(数据同步) */
|
||||
@Excel(name = "菜品计划id(数据同步)")
|
||||
@ApiModelProperty(value = "菜品计划id(数据同步)")
|
||||
private String planId;
|
||||
|
||||
/** 生效时间 */
|
||||
@ApiModelProperty(value = "生效时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "生效时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date effectDate;
|
||||
|
||||
/** 到期时间 */
|
||||
@ApiModelProperty(value = "到期时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "到期时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date expireDate;
|
||||
|
||||
private List<CookRecipeDateDTO> recipeDateList;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.bonus.canteen.core.cook.dto;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜品计划详情信息对象 cook_recipe_detail
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-05-25
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class CookRecipeDateDTO extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 启用时间(天) */
|
||||
@ApiModelProperty(value = "启用时间(天)")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "启用时间(天)", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date applyDate;
|
||||
|
||||
/** 启用时间(周) */
|
||||
@Excel(name = "启用时间(周)")
|
||||
@ApiModelProperty(value = "启用时间(周)")
|
||||
private Long applyWeek;
|
||||
|
||||
/** 启用时间(月) */
|
||||
@Excel(name = "启用时间(月)")
|
||||
@ApiModelProperty(value = "启用时间(月)")
|
||||
private Long applyMonth;
|
||||
|
||||
List<CookRecipeDetailDTO> detailList;
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.bonus.canteen.core.cook.dto;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜品计划详情信息对象 cook_recipe_detail
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-05-25
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class CookRecipeDetailDTO extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 菜谱详情id */
|
||||
private Long recipeDetailId;
|
||||
|
||||
/** 菜品计划销售类别id(数据同步) */
|
||||
@Excel(name = "菜品计划销售类别id(数据同步)")
|
||||
@ApiModelProperty(value = "菜品计划销售类别id(数据同步)")
|
||||
private String saleTypeId;
|
||||
|
||||
/** 菜谱id */
|
||||
@Excel(name = "菜谱id")
|
||||
@ApiModelProperty(value = "菜谱id")
|
||||
private Long recipeId;
|
||||
|
||||
/** 启用时间(天) */
|
||||
@ApiModelProperty(value = "启用时间(天)")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "启用时间(天)", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date applyDate;
|
||||
|
||||
/** 启用时间(周) */
|
||||
@Excel(name = "启用时间(周)")
|
||||
@ApiModelProperty(value = "启用时间(周)")
|
||||
private Long applyWeek;
|
||||
|
||||
/** 启用时间(月) */
|
||||
@Excel(name = "启用时间(月)")
|
||||
@ApiModelProperty(value = "启用时间(月)")
|
||||
private Long applyMonth;
|
||||
|
||||
/** 餐次类型 */
|
||||
@Excel(name = "餐次类型")
|
||||
@ApiModelProperty(value = "餐次类型")
|
||||
private Long mealtimeType;
|
||||
|
||||
/** 详情类型(1-模板,2-详情) */
|
||||
@Excel(name = "详情类型(1-模板,2-详情)")
|
||||
@ApiModelProperty(value = "详情类型(1-模板,2-详情)")
|
||||
private Long detailType;
|
||||
|
||||
private List<CookRecipeDishesDTO> dishesList;
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package com.bonus.canteen.core.cook.dto;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 菜品计划菜品关联对象 cook_recipe_dishes
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-05-25
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class CookRecipeDishesDTO extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键id */
|
||||
private Long id;
|
||||
|
||||
/** 菜谱详情id */
|
||||
@Excel(name = "菜谱详情id")
|
||||
@ApiModelProperty(value = "菜谱详情id")
|
||||
private Long recipeDetailId;
|
||||
|
||||
/** 菜品id */
|
||||
@Excel(name = "菜品id")
|
||||
@ApiModelProperty(value = "菜品id")
|
||||
private Long dishesId;
|
||||
|
||||
/** 菜品单价 */
|
||||
@Excel(name = "菜品单价")
|
||||
@ApiModelProperty(value = "菜品单价")
|
||||
private Long price;
|
||||
|
||||
/** 菜品售价(优惠价) */
|
||||
@Excel(name = "菜品售价(优惠价)")
|
||||
@ApiModelProperty(value = "菜品售价(优惠价)")
|
||||
private Long salePrice;
|
||||
|
||||
/** 规格类型(1-标准,2-大份,3-小份,4-50g,5-100g) */
|
||||
@Excel(name = "规格类型(1-标准,2-大份,3-小份,4-50g,5-100g)")
|
||||
@ApiModelProperty(value = "规格类型(1-标准,2-大份,3-小份,4-50g,5-100g)")
|
||||
private Long sizeType;
|
||||
|
||||
/** 供应数量 */
|
||||
@Excel(name = "供应数量")
|
||||
@ApiModelProperty(value = "供应数量")
|
||||
private Long supplyNum;
|
||||
|
||||
/** 销售数量 */
|
||||
@Excel(name = "销售数量")
|
||||
@ApiModelProperty(value = "销售数量")
|
||||
private Long saleNum;
|
||||
|
||||
/** 剩余数量 */
|
||||
@Excel(name = "剩余数量")
|
||||
@ApiModelProperty(value = "剩余数量")
|
||||
private Integer remanentNum;
|
||||
|
||||
/** 个人限购数量 */
|
||||
@Excel(name = "个人限购数量")
|
||||
@ApiModelProperty(value = "个人限购数量")
|
||||
private Long limitNum;
|
||||
|
||||
/** 厨师id */
|
||||
@Excel(name = "厨师id")
|
||||
@ApiModelProperty(value = "厨师id")
|
||||
private Long chefId;
|
||||
|
||||
/** 是否推荐(1-推荐,2-不推荐) */
|
||||
@Excel(name = "是否推荐(1-推荐,2-不推荐)")
|
||||
@ApiModelProperty(value = "是否推荐(1-推荐,2-不推荐)")
|
||||
private Long recommendFlag;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.bonus.canteen.core.cook.mapper;
|
|||
|
||||
import java.util.List;
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipe;
|
||||
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
|
||||
|
||||
/**
|
||||
* 菜品计划信息Mapper接口
|
||||
|
|
@ -29,10 +30,10 @@ public interface CookRecipeMapper {
|
|||
/**
|
||||
* 新增菜品计划信息
|
||||
*
|
||||
* @param cookRecipe 菜品计划信息
|
||||
* @param cookRecipeDTO 菜品计划信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCookRecipe(CookRecipe cookRecipe);
|
||||
public int insertCookRecipe(CookRecipeDTO cookRecipeDTO);
|
||||
|
||||
/**
|
||||
* 修改菜品计划信息
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.canteen.core.cook.service;
|
|||
|
||||
import java.util.List;
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipe;
|
||||
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
|
||||
|
||||
/**
|
||||
* 菜品计划信息Service接口
|
||||
|
|
@ -29,10 +30,10 @@ public interface ICookRecipeService {
|
|||
/**
|
||||
* 新增菜品计划信息
|
||||
*
|
||||
* @param cookRecipe 菜品计划信息
|
||||
* @param cookRecipeDTO 菜品计划信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCookRecipe(CookRecipe cookRecipe);
|
||||
public int insertCookRecipe(CookRecipeDTO cookRecipeDTO);
|
||||
|
||||
/**
|
||||
* 修改菜品计划信息
|
||||
|
|
|
|||
|
|
@ -1,13 +1,25 @@
|
|||
package com.bonus.canteen.core.cook.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
|
||||
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
|
||||
import com.bonus.canteen.core.cook.dto.CookRecipeDateDTO;
|
||||
import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO;
|
||||
import com.bonus.canteen.core.cook.dto.CookRecipeDishesDTO;
|
||||
import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper;
|
||||
import com.bonus.canteen.core.cook.mapper.CookRecipeDishesMapper;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.canteen.core.cook.mapper.CookRecipeMapper;
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipe;
|
||||
import com.bonus.canteen.core.cook.service.ICookRecipeService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 菜品计划信息Service业务层处理
|
||||
|
|
@ -19,6 +31,10 @@ import com.bonus.canteen.core.cook.service.ICookRecipeService;
|
|||
public class CookRecipeServiceImpl implements ICookRecipeService {
|
||||
@Autowired
|
||||
private CookRecipeMapper cookRecipeMapper;
|
||||
@Autowired
|
||||
private CookRecipeDetailMapper cookRecipeDetailMapper;
|
||||
@Autowired
|
||||
private CookRecipeDishesMapper cookRecipeDishesMapper;
|
||||
|
||||
/**
|
||||
* 查询菜品计划信息
|
||||
|
|
@ -45,14 +61,34 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
|||
/**
|
||||
* 新增菜品计划信息
|
||||
*
|
||||
* @param cookRecipe 菜品计划信息
|
||||
* @param cookRecipeDTO 菜品计划信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCookRecipe(CookRecipe cookRecipe) {
|
||||
cookRecipe.setCreateTime(DateUtils.getNowDate());
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertCookRecipe(CookRecipeDTO cookRecipeDTO) {
|
||||
cookRecipeDTO.setCreateTime(DateUtils.getNowDate());
|
||||
cookRecipeDTO.setCreateBy(SecurityUtils.getUsername());
|
||||
try {
|
||||
return cookRecipeMapper.insertCookRecipe(cookRecipe);
|
||||
int count = cookRecipeMapper.insertCookRecipe(cookRecipeDTO); //插入菜谱
|
||||
List<CookRecipeDateDTO> recipeDateList = cookRecipeDTO.getRecipeDateList();
|
||||
for (CookRecipeDateDTO recipeDateDTO : recipeDateList) {
|
||||
List<CookRecipeDetailDTO> detailList = recipeDateDTO.getDetailList();
|
||||
for (CookRecipeDetailDTO detailDTO : detailList) {
|
||||
CookRecipeDetail cookRecipeDetail = new CookRecipeDetail();
|
||||
BeanUtils.copyProperties(detailDTO, cookRecipeDetail);
|
||||
cookRecipeDetail.setRecipeId(cookRecipeDTO.getRecipeId());
|
||||
cookRecipeDetailMapper.insertCookRecipeDetail(cookRecipeDetail); //插入菜谱之执行计划
|
||||
List<CookRecipeDishesDTO> dishesList = detailDTO.getDishesList();
|
||||
for (CookRecipeDishesDTO dishesDTO : dishesList) {
|
||||
CookRecipeDishes cookRecipeDishes = new CookRecipeDishes();
|
||||
BeanUtils.copyProperties(dishesDTO, cookRecipeDishes);
|
||||
cookRecipeDishes.setRecipeDetailId(detailDTO.getRecipeDetailId());
|
||||
cookRecipeDishesMapper.insertCookRecipeDishes(cookRecipeDishes); //插入菜谱之菜品详情
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue