菜品查询、修改、删除
This commit is contained in:
parent
bfeb28a945
commit
8d6d145dff
|
|
@ -138,4 +138,15 @@ public class MenuDishesController extends BaseController {
|
|||
public AjaxResult remove(@RequestBody LongIds ids) {
|
||||
return toAjax(menuDishesService.deleteMenuDishesByIds(ids.getIds()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看菜品信息")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("menu:dishes:remove")
|
||||
@SysLog(title = "查看菜品信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品信息")
|
||||
@PostMapping("/check")
|
||||
public AjaxResult check(@RequestBody MenuDishesDTO menuDishesDTO) {
|
||||
return success(menuDishesService.check(menuDishesDTO));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bonus.canteen.core.common.utils.FileUrlUtil;
|
||||
import com.bonus.canteen.core.menu.dto.MenuDishesAddMaterialDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
|
@ -199,6 +202,104 @@ public class MenuDishes extends Model<MenuDishes> {
|
|||
@TableField(exist = false)
|
||||
private String areaName;
|
||||
|
||||
@Getter
|
||||
@ApiModelProperty("原材料")
|
||||
@TableField(exist = false)
|
||||
private @Valid List<MenuDishesAddMaterialDTO> materialList;
|
||||
|
||||
@Getter
|
||||
@ApiModelProperty("标签id")
|
||||
@TableField(exist = false)
|
||||
private List<Integer> labelIdList;
|
||||
|
||||
@Getter
|
||||
@ApiModelProperty("口味id")
|
||||
private @Size( max = 3,message = "口味最多配置3个")
|
||||
@TableField(exist = false)
|
||||
List<Integer> tasteIdList;
|
||||
|
||||
@Getter
|
||||
@ApiModelProperty("季节分类")
|
||||
@TableField(exist = false)
|
||||
private List<Integer> season;
|
||||
|
||||
@Getter
|
||||
@ApiModelProperty("适宜人群")
|
||||
@TableField(exist = false)
|
||||
private List<Integer> suitIdList;
|
||||
|
||||
@Getter
|
||||
@ApiModelProperty("餐次")
|
||||
@TableField(exist = false)
|
||||
private List<Integer> mealList;
|
||||
|
||||
@Getter
|
||||
@TableField(exist = false)
|
||||
private String labelId;
|
||||
|
||||
@Getter
|
||||
@TableField(exist = false)
|
||||
private String tasteId;
|
||||
|
||||
@Getter
|
||||
@TableField(exist = false)
|
||||
private String seasonId;
|
||||
|
||||
@Getter
|
||||
@TableField(exist = false)
|
||||
private String suitId;
|
||||
|
||||
@Getter
|
||||
@TableField(exist = false)
|
||||
private String mealId;
|
||||
|
||||
|
||||
|
||||
|
||||
public void setMaterialList(List<MenuDishesAddMaterialDTO> materialList) {
|
||||
this.materialList = materialList;
|
||||
}
|
||||
|
||||
public void setLabelIdList(List<Integer> labelIdList) {
|
||||
this.labelIdList = labelIdList;
|
||||
}
|
||||
|
||||
public void setTasteIdList(List<Integer> tasteIdList) {
|
||||
this.tasteIdList = tasteIdList;
|
||||
}
|
||||
|
||||
public void setSeason(List<Integer> season) {
|
||||
this.season = season;
|
||||
}
|
||||
|
||||
public void setSuitIdList(List<Integer> suitIdList) {
|
||||
this.suitIdList = suitIdList;
|
||||
}
|
||||
|
||||
public void setMealList(List<Integer> mealList) {
|
||||
this.mealList = mealList;
|
||||
}
|
||||
|
||||
public void setLabelId(String labelId) {
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
public void setTasteId(String tasteId) {
|
||||
this.tasteId = tasteId;
|
||||
}
|
||||
|
||||
public void setSeasonId(String seasonId) {
|
||||
this.seasonId = seasonId;
|
||||
}
|
||||
|
||||
public void setSuitId(String suitId) {
|
||||
this.suitId = suitId;
|
||||
}
|
||||
|
||||
public void setMealId(String mealId) {
|
||||
this.mealId = mealId;
|
||||
}
|
||||
|
||||
public void setAreaName(String areaName) {
|
||||
this.areaName = areaName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,4 +81,9 @@ public interface MenuDishesMapper {
|
|||
NutritionEntity getNutritionEntity(MenuDishesAddMaterialDTO dto);
|
||||
|
||||
int addFinalNutrition(@Param("nutritionEntity") NutritionEntity nutritionEntity,@Param("dishesId") Long dishesId);
|
||||
|
||||
|
||||
int addMenuMaterialDishes(@Param("dishesId")Long dishesId,@Param("materialList") List<MenuDishesAddMaterialDTO> materialList);
|
||||
List<MenuDishesAddMaterialDTO> getMenuMaterialDishes(String deshesId);
|
||||
MenuDishes getDishMessageByDishesId(String dishesId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,4 +64,6 @@ public interface IMenuDishesService {
|
|||
List<MapBean> getDishesType(MapBean mapBean);
|
||||
|
||||
int addMenuDishes(MenuDishesDTO menuDishesDTO);
|
||||
|
||||
MenuDishes check(MenuDishesDTO menuDishesDTO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -199,6 +200,8 @@ public class MenuDishesServiceImpl implements IMenuDishesService {
|
|||
nutritionEntityList.add(nutritionEntity);
|
||||
}
|
||||
}
|
||||
//添加菜品和材料关系表
|
||||
menuDishesMapper.addMenuMaterialDishes(dishesId,materialList);
|
||||
NutritionEntityUtil nutritionEntityUtil = new NutritionEntityUtil();
|
||||
NutritionEntity nutritionEntity = nutritionEntityUtil.countNutrition(nutritionEntityList);
|
||||
if(nutritionEntityList !=null && nutritionEntityList.size() >0){
|
||||
|
|
@ -291,4 +294,56 @@ public class MenuDishesServiceImpl implements IMenuDishesService {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MenuDishes check(MenuDishesDTO menuDishesDTO) {
|
||||
if(menuDishesDTO.getDishesId() == null){
|
||||
throw new ServiceException("菜品ID不能为空");
|
||||
}
|
||||
MenuDishes menuDishesDTO1 = menuDishesMapper.getDishMessageByDishesId(menuDishesDTO.getDishesId());
|
||||
List<MenuDishesAddMaterialDTO> menuDishesAddMaterialDTO= menuDishesMapper.getMenuMaterialDishes(menuDishesDTO.getDishesId());
|
||||
if(menuDishesAddMaterialDTO !=null){
|
||||
menuDishesDTO1.setMaterialList(menuDishesAddMaterialDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
List<Integer> mealList = new ArrayList<>();
|
||||
if (menuDishesDTO1.getLabelId() !=null && !menuDishesDTO1.getLabelId().isEmpty()){
|
||||
List<Integer> list = Arrays.stream(menuDishesDTO1.getLabelId().split("\\s*,\\s*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
menuDishesDTO1.setLabelIdList(list);
|
||||
}
|
||||
if (menuDishesDTO1.getTasteId()!=null && !menuDishesDTO1.getTasteId().isEmpty()){
|
||||
List<Integer> list = Arrays.stream(menuDishesDTO1.getTasteId().split("\\s*,\\s*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
menuDishesDTO1.setTasteIdList(list);
|
||||
}
|
||||
if (menuDishesDTO1.getSeasonId() !=null && !menuDishesDTO1.getSeasonId().isEmpty()){
|
||||
List<Integer> list = Arrays.stream(menuDishesDTO1.getSeasonId().split("\\s*,\\s*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
menuDishesDTO1.setSeason(list);
|
||||
|
||||
}
|
||||
if(menuDishesDTO1.getSuitId() !=null && !menuDishesDTO1.getSuitId().isEmpty()){
|
||||
List<Integer> list = Arrays.stream(menuDishesDTO1.getSuitId().split("\\s*,\\s*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
menuDishesDTO1.setSuitIdList(list);
|
||||
|
||||
}
|
||||
if(menuDishesDTO1.getMealId() !=null && !menuDishesDTO1.getMealId().isEmpty()){
|
||||
List<Integer> list = Arrays.stream(menuDishesDTO1.getMealId().split("\\s*,\\s*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
menuDishesDTO1.setMealList(list);
|
||||
}
|
||||
|
||||
|
||||
return menuDishesDTO1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -527,4 +527,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
where dishes_id = #{dishesId}
|
||||
</update>
|
||||
|
||||
<insert id="addMenuMaterialDishes" parameterType="java.util.List">
|
||||
insert into menu_material_dishes(dishes_id,material_id,weight,material_type)
|
||||
|
||||
values
|
||||
<foreach collection="materialList" item="item" separator=",">
|
||||
(#{dishesId}, #{item.materialId}, #{item.weight}, #{item.materialType})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getMenuMaterialDishes" resultType="com.bonus.canteen.core.menu.dto.MenuDishesAddMaterialDTO">
|
||||
select material_id as materialId,weight,material_type as materialType from menu_material_dishes where dishes_id = #{dishesId}
|
||||
</select>
|
||||
|
||||
<select id="getDishMessageByDishesId" resultType="com.bonus.canteen.core.menu.domain.MenuDishes">
|
||||
<include refid="selectMenuDishesVo"/>
|
||||
where b.dishes_id = #{dishesId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue