菜品管理页面
This commit is contained in:
		| @@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.stdiet.common.annotation.Excel; | ||||
| import com.stdiet.common.core.domain.BaseEntity; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 菜品对象 sys_dishes | ||||
|  *  | ||||
| @@ -30,6 +32,8 @@ public class SysDishes extends BaseEntity | ||||
|     @Excel(name = "做法") | ||||
|     private String methods; | ||||
|  | ||||
|     private List<SysDishesIngredient> igdList; | ||||
|  | ||||
|     public void setId(Long id)  | ||||
|     { | ||||
|         this.id = id; | ||||
| @@ -67,6 +71,14 @@ public class SysDishes extends BaseEntity | ||||
|         return methods; | ||||
|     } | ||||
|  | ||||
|     public void setIgdList(List<SysDishesIngredient> ingredientList) { | ||||
|         this.igdList = ingredientList; | ||||
|     } | ||||
|  | ||||
|     public List<SysDishesIngredient> getIgdList() { | ||||
|         return igdList; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||||
|   | ||||
| @@ -0,0 +1,76 @@ | ||||
| package com.stdiet.custom.domain; | ||||
|  | ||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | ||||
| import org.apache.commons.lang3.builder.ToStringStyle; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
|  | ||||
| /** | ||||
|  * 菜品对象 sys_dishes | ||||
|  * | ||||
|  * @author wonder | ||||
|  * @date 2020-12-28 | ||||
|  */ | ||||
| public class SysDishesIngredient extends SysIngredient { | ||||
|  | ||||
|     private Long ingredientId; | ||||
|  | ||||
|     private Long dishesId; | ||||
|  | ||||
|     private Long cusUnit; | ||||
|  | ||||
|     private BigDecimal cusWeight; | ||||
|  | ||||
|     private BigDecimal weight; | ||||
|  | ||||
|     public Long getIngredientId() { | ||||
|         return ingredientId; | ||||
|     } | ||||
|  | ||||
|     public void setIngredientId(Long ingredientId) { | ||||
|         this.ingredientId = ingredientId; | ||||
|     } | ||||
|  | ||||
|     public Long getDishesId() { | ||||
|         return dishesId; | ||||
|     } | ||||
|  | ||||
|     public void setDishesId(Long dishesId) { | ||||
|         this.dishesId = dishesId; | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getWeight() { | ||||
|         return weight; | ||||
|     } | ||||
|  | ||||
|     public void setWeight(BigDecimal weight) { | ||||
|         this.weight = weight; | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getCusWeight() { | ||||
|         return cusWeight; | ||||
|     } | ||||
|  | ||||
|     public void setCusWeight(BigDecimal cusWeight) { | ||||
|         this.cusWeight = cusWeight; | ||||
|     } | ||||
|  | ||||
|     public Long getCusUnit() { | ||||
|         return cusUnit; | ||||
|     } | ||||
|  | ||||
|     public void setCusUnit(Long cusUnit) { | ||||
|         this.cusUnit = cusUnit; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) | ||||
|                 .append("ingredientId", getIngredientId()) | ||||
|                 .append("dishesId", getDishesId()) | ||||
|                 .append("weight", getWeight()) | ||||
|                 .append("cusWeight", getCusWeight()) | ||||
|                 .append("cusUnit", getCusUnit()) | ||||
|                 .toString(); | ||||
|     } | ||||
| } | ||||
| @@ -33,24 +33,6 @@ public class SysIngredient extends BaseEntity { | ||||
|     @Excel(name = "食材类别") | ||||
|     private String type; | ||||
|  | ||||
|     /** | ||||
|      * 推荐分量估算 | ||||
|      */ | ||||
|     @Excel(name = "推荐分量估算") | ||||
|     private Long recEstimation; | ||||
|  | ||||
|     /** | ||||
|      * 推荐分量估算单位id | ||||
|      */ | ||||
|     @Excel(name = "推荐分量估算单位id") | ||||
|     private Long recEstUnit; | ||||
|  | ||||
|     /** | ||||
|      * 推荐分量 | ||||
|      */ | ||||
|     @Excel(name = "推荐分量") | ||||
|     private Long recPortion; | ||||
|  | ||||
|     /** | ||||
|      * 蛋白质比例 | ||||
|      */ | ||||
| @@ -123,30 +105,6 @@ public class SysIngredient extends BaseEntity { | ||||
|         this.type = type; | ||||
|     } | ||||
|  | ||||
|     public Long getRecEstimation() { | ||||
|         return recEstimation; | ||||
|     } | ||||
|  | ||||
|     public void setRecEstimation(Long recEstimation) { | ||||
|         this.recEstimation = recEstimation; | ||||
|     } | ||||
|  | ||||
|     public Long getRecEstUnit() { | ||||
|         return recEstUnit; | ||||
|     } | ||||
|  | ||||
|     public void setRecEstUnit(Long recEstUnit) { | ||||
|         this.recEstUnit = recEstUnit; | ||||
|     } | ||||
|  | ||||
|     public Long getRecPortion() { | ||||
|         return recPortion; | ||||
|     } | ||||
|  | ||||
|     public void setRecPortion(Long recPortion) { | ||||
|         this.recPortion = recPortion; | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getProteinRatio() { | ||||
|         return proteinRatio; | ||||
|     } | ||||
| @@ -201,9 +159,6 @@ public class SysIngredient extends BaseEntity { | ||||
|                 .append("id", getId()) | ||||
|                 .append("name", getName()) | ||||
|                 .append("type", getType()) | ||||
|                 .append("recEstimation", getRecEstimation()) | ||||
|                 .append("recEstUnit", getRecEstUnit()) | ||||
|                 .append("recPortion", getRecPortion()) | ||||
|                 .append("proteinRatio", getProteinRatio()) | ||||
|                 .append("fatRatio", getFatRatio()) | ||||
|                 .append("carbonRatio", getCarbonRatio()) | ||||
|   | ||||
| @@ -1,7 +1,11 @@ | ||||
| package com.stdiet.custom.mapper; | ||||
|  | ||||
| import java.lang.reflect.Array; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import com.stdiet.custom.domain.SysDishes; | ||||
| import com.stdiet.custom.domain.SysDishesIngredient; | ||||
| import com.stdiet.custom.domain.SysIngredient; | ||||
|  | ||||
| /** | ||||
|  * 菜品Mapper接口 | ||||
| @@ -19,6 +23,8 @@ public interface SysDishesMapper | ||||
|      */ | ||||
|     public SysDishes selectSysDishesById(Long id); | ||||
|  | ||||
|     public ArrayList<SysDishesIngredient> selectSysIngreditentsById(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 查询菜品列表 | ||||
|      *  | ||||
| @@ -58,4 +64,10 @@ public interface SysDishesMapper | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public int deleteSysDishesByIds(Long[] ids); | ||||
|  | ||||
|     public int deleteIngredientById(Long id); | ||||
|  | ||||
|     public int deleteIngredientByIds(Long[] ids); | ||||
|  | ||||
|     public int bashInsertDishesIngredent(List<SysDishesIngredient> sysDishesIngredients); | ||||
| } | ||||
| @@ -68,4 +68,8 @@ public interface SysIngredientMapper | ||||
|     public int deleteIngredentRecByIngredientId(Long recId); | ||||
|  | ||||
|     public int deleteIngredentNotRecByIngredientId(Long notRecId); | ||||
|  | ||||
|     public int deleteIngredentRecByIngredientIds(Long[] id); | ||||
|  | ||||
|     public int deleteIngredentNotRecByIngredientIds(Long[] id); | ||||
| } | ||||
| @@ -2,6 +2,8 @@ package com.stdiet.custom.service; | ||||
|  | ||||
| import java.util.List; | ||||
| import com.stdiet.custom.domain.SysDishes; | ||||
| import com.stdiet.custom.domain.SysDishesIngredient; | ||||
| import com.stdiet.custom.domain.SysIngredient; | ||||
|  | ||||
| /** | ||||
|  * 菜品Service接口 | ||||
| @@ -19,6 +21,8 @@ public interface ISysDishesService | ||||
|      */ | ||||
|     public SysDishes selectSysDishesById(Long id); | ||||
|  | ||||
|     public List<SysDishesIngredient> selectSysIngreditentsById(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 查询菜品列表 | ||||
|      *  | ||||
|   | ||||
| @@ -1,96 +1,127 @@ | ||||
| package com.stdiet.custom.service.impl; | ||||
|  | ||||
| import java.util.List; | ||||
| import com.stdiet.common.utils.DateUtils; | ||||
| import com.stdiet.common.utils.StringUtils; | ||||
| import com.stdiet.custom.domain.SysDishes; | ||||
| import com.stdiet.custom.domain.SysDishesIngredient; | ||||
| import com.stdiet.custom.mapper.SysDishesMapper; | ||||
| import com.stdiet.custom.service.ISysDishesService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| import com.stdiet.custom.mapper.SysDishesMapper; | ||||
| import com.stdiet.custom.domain.SysDishes; | ||||
| import com.stdiet.custom.service.ISysDishesService; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 菜品Service业务层处理 | ||||
|  *  | ||||
|  * | ||||
|  * @author wonder | ||||
|  * @date 2020-12-28 | ||||
|  */ | ||||
| @Service | ||||
| public class SysDishesServiceImpl implements ISysDishesService  | ||||
| { | ||||
| public class SysDishesServiceImpl implements ISysDishesService { | ||||
|     @Autowired | ||||
|     private SysDishesMapper sysDishesMapper; | ||||
|  | ||||
|     /** | ||||
|      * 查询菜品 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 菜品ID | ||||
|      * @return 菜品 | ||||
|      */ | ||||
|     @Override | ||||
|     public SysDishes selectSysDishesById(Long id) | ||||
|     { | ||||
|         return sysDishesMapper.selectSysDishesById(id); | ||||
|     public SysDishes selectSysDishesById(Long id) { | ||||
|         SysDishes dishes = sysDishesMapper.selectSysDishesById(id); | ||||
|         if (StringUtils.isNotNull(dishes)) { | ||||
|             List<SysDishesIngredient> ingredientArray = selectSysIngreditentsById(id); | ||||
|             if (StringUtils.isNull(ingredientArray)) { | ||||
|                 dishes.setIgdList(new ArrayList<>()); | ||||
|             } else { | ||||
|                 dishes.setIgdList(ingredientArray); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|         return dishes; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<SysDishesIngredient> selectSysIngreditentsById(Long id) { | ||||
|         return sysDishesMapper.selectSysIngreditentsById(id); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 查询菜品列表 | ||||
|      *  | ||||
|      * | ||||
|      * @param sysDishes 菜品 | ||||
|      * @return 菜品 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<SysDishes> selectSysDishesList(SysDishes sysDishes) | ||||
|     { | ||||
|     public List<SysDishes> selectSysDishesList(SysDishes sysDishes) { | ||||
|         return sysDishesMapper.selectSysDishesList(sysDishes); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增菜品 | ||||
|      *  | ||||
|      * | ||||
|      * @param sysDishes 菜品 | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     @Override | ||||
|     public int insertSysDishes(SysDishes sysDishes) | ||||
|     { | ||||
|     public int insertSysDishes(SysDishes sysDishes) { | ||||
|         sysDishes.setCreateTime(DateUtils.getNowDate()); | ||||
|         return sysDishesMapper.insertSysDishes(sysDishes); | ||||
|         int rows = sysDishesMapper.insertSysDishes(sysDishes); | ||||
|         // | ||||
|         insertDishesIngredient(sysDishes); | ||||
|         return rows; | ||||
|     } | ||||
|  | ||||
|     public void insertDishesIngredient(SysDishes sysDishes) { | ||||
|         if (StringUtils.isNotNull(sysDishes.getIgdList())) { | ||||
|             List<SysDishesIngredient> list = sysDishes.getIgdList(); | ||||
|             for (SysDishesIngredient dishesIngredient : list) { | ||||
|                 dishesIngredient.setDishesId(sysDishes.getId()); | ||||
|                 dishesIngredient.setIngredientId(dishesIngredient.getId()); | ||||
|             } | ||||
|             sysDishesMapper.bashInsertDishesIngredent(list); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 修改菜品 | ||||
|      *  | ||||
|      * | ||||
|      * @param sysDishes 菜品 | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     @Override | ||||
|     public int updateSysDishes(SysDishes sysDishes) | ||||
|     { | ||||
|     public int updateSysDishes(SysDishes sysDishes) { | ||||
|         sysDishes.setUpdateTime(DateUtils.getNowDate()); | ||||
|         Long dishesId = sysDishes.getId(); | ||||
|         sysDishesMapper.deleteIngredientById(dishesId); | ||||
|         insertDishesIngredient(sysDishes); | ||||
|         return sysDishesMapper.updateSysDishes(sysDishes); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 批量删除菜品 | ||||
|      *  | ||||
|      * | ||||
|      * @param ids 需要删除的菜品ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     @Override | ||||
|     public int deleteSysDishesByIds(Long[] ids) | ||||
|     { | ||||
|     public int deleteSysDishesByIds(Long[] ids) { | ||||
|         sysDishesMapper.deleteIngredientByIds(ids); | ||||
|         return sysDishesMapper.deleteSysDishesByIds(ids); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 删除菜品信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 菜品ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     @Override | ||||
|     public int deleteSysDishesById(Long id) | ||||
|     { | ||||
|     public int deleteSysDishesById(Long id) { | ||||
|         sysDishesMapper.deleteIngredientById(id); | ||||
|         return sysDishesMapper.deleteSysDishesById(id); | ||||
|     } | ||||
| } | ||||
| @@ -128,6 +128,8 @@ public class SysIngredientServiceImpl implements ISysIngredientService { | ||||
|      */ | ||||
|     @Override | ||||
|     public int deleteSysIngredientByIds(Long[] ids) { | ||||
|         sysIngredientMapper.deleteIngredentRecByIngredientIds(ids); | ||||
|         sysIngredientMapper.deleteIngredentNotRecByIngredientIds(ids); | ||||
|         return sysIngredientMapper.deleteSysIngredientByIds(ids); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user