From afb7465281893e7170f12fe658bf2ec91f0d020a Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Tue, 9 Feb 2021 10:25:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E4=BF=97=E9=87=8D?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysIngredientController.java | 13 +- .../custom/SysRecipesController.java | 23 +++ .../com/stdiet/custom/domain/SysDishes.java | 122 +++++--------- .../custom/domain/SysDishesIngredient.java | 4 +- .../domain/SysDishesIngredientInfo.java | 25 +++ .../stdiet/custom/domain/SysIngredient.java | 159 ++++-------------- .../com/stdiet/custom/domain/SysRecipes.java | 47 ++++++ .../custom/mapper/SysRecipesMapper.java | 10 ++ .../custom/service/ISysRecipesService.java | 9 + .../service/impl/SysRecipesServiceImpl.java | 23 +++ .../custom/typehandler/ArrayJsonHandler.java | 56 ++++++ .../custom/typehandler/ObjectJsonHandler.java | 57 +++++++ .../mapper/custom/SysDishesMapper.xml | 7 +- .../mapper/custom/SysRecipesMapper.xml | 76 +++++++++ stdiet-ui/src/api/custom/ingredient.js | 2 +- .../src/components/RecipesView/index.vue | 25 +++ stdiet-ui/src/router/index.js | 2 +- stdiet-ui/src/store/index.js | 27 +-- stdiet-ui/src/store/modules/recipes.js | 50 ++++++ stdiet-ui/src/views/custom/dishes/index.vue | 6 +- .../custom/recipesBuild/BodySignView.vue | 9 +- .../views/custom/recipesBuild/HealthyView.vue | 9 +- .../views/custom/recipesBuild/TextInfo.vue | 18 +- .../src/views/custom/recipesBuild/index.vue | 76 +++++---- .../src/views/custom/recipesPlan/build.vue | 38 ----- .../src/views/custom/recipesPlan/index.vue | 20 ++- 26 files changed, 580 insertions(+), 333 deletions(-) create mode 100644 stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesController.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredientInfo.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipes.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesMapper.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesService.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ArrayJsonHandler.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ObjectJsonHandler.java create mode 100644 stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml create mode 100644 stdiet-ui/src/components/RecipesView/index.vue create mode 100644 stdiet-ui/src/store/modules/recipes.js delete mode 100644 stdiet-ui/src/views/custom/recipesPlan/build.vue diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java index f8100f17f..e28d40ab7 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java @@ -1,16 +1,11 @@ package com.stdiet.web.controller.custom; import java.util.List; + +import com.github.pagehelper.PageHelper; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.stdiet.common.annotation.Log; import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.domain.AjaxResult; @@ -38,7 +33,7 @@ public class SysIngredientController extends BaseController */ @PreAuthorize("@ss.hasPermi('custom:ingredient:list')") @PostMapping("/list") - public TableDataInfo list(@RequestBody SysIngredient sysIngredient) + public TableDataInfo list(@RequestParam Integer pageSize, @RequestParam Integer pageNum, @RequestBody SysIngredient sysIngredient) { startPage(); List list = sysIngredientService.selectSysIngredientList(sysIngredient); diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesController.java new file mode 100644 index 000000000..0ba05c017 --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesController.java @@ -0,0 +1,23 @@ +package com.stdiet.web.controller.custom; + +import com.stdiet.common.core.controller.BaseController; +import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.custom.service.ISysRecipesService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/recipes") +public class SysRecipesController extends BaseController { + + @Autowired + private ISysRecipesService sysRecipesService; + + @GetMapping(value = "/{resipesId}") + public AjaxResult getInfo(@PathVariable("resipesId") Long resipesId) { + return AjaxResult.success(sysRecipesService.selectSysRecipesByRecipesId(resipesId)); + } +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishes.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishes.java index 8f64679c4..61bd86838 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishes.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishes.java @@ -1,34 +1,42 @@ package com.stdiet.custom.domain; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; +import com.fasterxml.jackson.annotation.JsonFormat; import com.stdiet.common.annotation.Excel; -import com.stdiet.common.core.domain.BaseEntity; +import lombok.Data; +import java.util.Date; import java.util.List; /** * 菜品对象 sys_dishes - * + * * @author wonder * @date 2020-12-28 */ -public class SysDishes extends BaseEntity -{ +@Data +public class SysDishes { private static final long serialVersionUID = 1L; - /** id */ + /** + * id + */ private Long id; - /** 菜品名称 */ + /** + * 菜品名称 + */ @Excel(name = "菜品名称") private String name; - /** 菜品类型 */ + /** + * 菜品类型 + */ @Excel(name = "菜品类型") private String type; - /** 做法 */ + /** + * 做法 + */ @Excel(name = "做法") private String methods; @@ -36,80 +44,36 @@ public class SysDishes extends BaseEntity private String reviewStatus; - public Integer getIsMain() { - return isMain; - } + /** + * 创建者 + */ + private String createBy; - public void setIsMain(Integer isMain) { - this.isMain = isMain; - } + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; - public void setReviewStatus(String reviewStatus) { - this.reviewStatus = reviewStatus; - } + /** + * 更新者 + */ + private String updateBy; + + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** + * 备注 + */ + private String remark; - public String getReviewStatus() { - return reviewStatus; - } private List igdList; - public void setId(Long id) - { - this.id = id; - } + private List detail; - public Long getId() - { - return id; - } - public void setName(String name) - { - this.name = name; - } - - public String getName() - { - return name; - } - public void setType(String type) - { - this.type = type; - } - - public String getType() - { - return type; - } - public void setMethods(String methods) - { - this.methods = methods; - } - - public String getMethods() - { - return methods; - } - - public void setIgdList(List ingredientList) { - this.igdList = ingredientList; - } - - public List getIgdList() { - return igdList; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("type", getType()) - .append("methods", getMethods()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredient.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredient.java index af03ca135..f158153be 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredient.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredient.java @@ -21,9 +21,9 @@ public class SysDishesIngredient extends SysIngredient { private Long cusUnit; - private BigDecimal cusWeight; +// private BigDecimal cusWeight; - private Integer cusWei; + private Integer cusWeight; private BigDecimal weight; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredientInfo.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredientInfo.java new file mode 100644 index 000000000..4c6e0295f --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishesIngredientInfo.java @@ -0,0 +1,25 @@ +package com.stdiet.custom.domain; + +import lombok.Data; + +/** + * 食材对象 sys_ingredient + * + * @author wonder + * @date 2020-12-15 + */ +@Data +public class SysDishesIngredientInfo { + private static final long serialVersionUID = 1L; + + private Long id; + + private String cus_unit; + + private String cus_weight; + + private Integer weight; + + private String remark; + +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java index 4b45d85b0..c5cd66719 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java @@ -1,11 +1,11 @@ package com.stdiet.custom.domain; +import com.fasterxml.jackson.annotation.JsonFormat; import com.stdiet.common.annotation.Excel; -import com.stdiet.common.core.domain.BaseEntity; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; +import lombok.Data; import java.math.BigDecimal; +import java.util.Date; /** * 食材对象 sys_ingredient @@ -13,12 +13,10 @@ import java.math.BigDecimal; * @author wonder * @date 2020-12-15 */ -public class SysIngredient extends BaseEntity { +@Data +public class SysIngredient { private static final long serialVersionUID = 1L; - private int pageNum; - private int pageSize; - /** * id */ @@ -77,131 +75,36 @@ public class SysIngredient extends BaseEntity { */ private String reviewStatus; - public void setReviewStatus(String reviewStatus) { - this.reviewStatus = reviewStatus; - } + /** + * 创建者 + */ + private String createBy; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** + * 更新者 + */ + private String updateBy; + + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** + * 备注 + */ + private String remark; - public String getReviewStatus() { - return reviewStatus; - } private Long[] recIds; private Long[] notRecIds; - public Long[] getRecIds() { - return recIds; - } - - public Long[] getNotRecIds() { - return notRecIds; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public BigDecimal getProteinRatio() { - return proteinRatio; - } - - public void setProteinRatio(BigDecimal proteinRatio) { - this.proteinRatio = proteinRatio; - } - - public BigDecimal getFatRatio() { - return fatRatio; - } - - public void setFatRatio(BigDecimal fatRatio) { - this.fatRatio = fatRatio; - } - - public BigDecimal getCarbonRatio() { - return carbonRatio; - } - - public void setCarbonRatio(BigDecimal carbonRatio) { - this.carbonRatio = carbonRatio; - } - - public String getArea() { - return area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getNotRec() { - return notRec; - } - - public void setNotRec(String notRec) { - this.notRec = notRec; - } - - public String getRec() { - return rec; - } - - public void setRec(String rec) { - this.rec = rec; - } - - public void setPageNum(int pageNum) { - this.pageNum = pageNum; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public int getPageNum() { - return pageNum; - } - - public int getPageSize() { - return pageSize; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("type", getType()) - .append("proteinRatio", getProteinRatio()) - .append("fatRatio", getFatRatio()) - .append("carbonRatio", getCarbonRatio()) - .append("remark", getRemark()) - .append("area", getArea()) - .append("notRec", getNotRec()) - .append("recommend", getRec()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipes.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipes.java new file mode 100644 index 000000000..9b727297d --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipes.java @@ -0,0 +1,47 @@ +package com.stdiet.custom.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class SysRecipes { + private static final long serialVersionUID = 1L; + + private Long id; + + private Integer numDay; + + private List dishes; + + private Integer reviewStatus; + + /** + * 创建者 + */ + private String createBy; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** + * 更新者 + */ + private String updateBy; + + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** + * 备注 + */ + private String remark; +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesMapper.java new file mode 100644 index 000000000..e0bfdcc0a --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesMapper.java @@ -0,0 +1,10 @@ +package com.stdiet.custom.mapper; + +import com.stdiet.custom.domain.SysRecipes; + +import java.util.List; + +public interface SysRecipesMapper { + + public List selectSysRecipesByRecipesId(Long id); +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesService.java new file mode 100644 index 000000000..5bf1c4a39 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesService.java @@ -0,0 +1,9 @@ +package com.stdiet.custom.service; + +import com.stdiet.custom.domain.SysRecipes; + +import java.util.List; + +public interface ISysRecipesService { + public List selectSysRecipesByRecipesId(Long id); +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java new file mode 100644 index 000000000..a899e98c4 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java @@ -0,0 +1,23 @@ +package com.stdiet.custom.service.impl; + +import com.stdiet.custom.domain.SysRecipes; +import com.stdiet.custom.mapper.SysRecipesMapper; +import com.stdiet.custom.service.ISysRecipesService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Transactional +public class SysRecipesServiceImpl implements ISysRecipesService { + + @Autowired + private SysRecipesMapper sysRecipesMapper; + + @Override + public List selectSysRecipesByRecipesId(Long id) { + return sysRecipesMapper.selectSysRecipesByRecipesId(id); + } +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ArrayJsonHandler.java b/stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ArrayJsonHandler.java new file mode 100644 index 000000000..9b274c1d0 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ArrayJsonHandler.java @@ -0,0 +1,56 @@ +package com.stdiet.custom.typehandler; + +import com.alibaba.fastjson.JSONArray; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Created by lixio on 2019/3/28 20:51 + * @description 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONArray属性 + * MappedTypes注解中的类代表此转换器可以自动转换为的java对象 + * MappedJdbcTypes注解中设置的是对应的jdbctype + */ +@MappedTypes(JSONArray.class) +@MappedJdbcTypes(JdbcType.VARCHAR) +public class ArrayJsonHandler extends BaseTypeHandler { + //设置非空参数 + @Override + public void setNonNullParameter(PreparedStatement ps, int i, JSONArray parameter, JdbcType jdbcType) throws SQLException { + ps.setString(i, String.valueOf(parameter.toJSONString())); + } + //根据列名,获取可以为空的结果 + @Override + public JSONArray getNullableResult(ResultSet rs, String columnName) throws SQLException { + String sqlJson = rs.getString(columnName); + if (null != sqlJson){ + return JSONArray.parseArray(sqlJson); + } + return null; + } + //根据列索引,获取可以为空的结果 + @Override + public JSONArray getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + String sqlJson = rs.getString(columnIndex); + if (null != sqlJson){ + return JSONArray.parseArray(sqlJson); + } + return null; + } + + @Override + public JSONArray getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { + String sqlJson = cs.getString(columnIndex); + if (null != sqlJson){ + return JSONArray.parseArray(sqlJson); + } + return null; + } + +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ObjectJsonHandler.java b/stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ObjectJsonHandler.java new file mode 100644 index 000000000..d02c8c2b5 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/typehandler/ObjectJsonHandler.java @@ -0,0 +1,57 @@ +package com.stdiet.custom.typehandler; + +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Created by lixio on 2019/3/28 15:44 + * @description 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONObject属性 + * MappedTypes注解中的类代表此转换器可以自动转换为的java对象 + * MappedJdbcTypes注解中设置的是对应的jdbctype + */ + +@MappedTypes(JSONObject.class) +@MappedJdbcTypes(JdbcType.VARCHAR) +public class ObjectJsonHandler extends BaseTypeHandler{ + + //设置非空参数 + @Override + public void setNonNullParameter(PreparedStatement ps, int i, JSONObject parameter, JdbcType jdbcType) throws SQLException { + ps.setString(i, String.valueOf(parameter.toJSONString())); + } + //根据列名,获取可以为空的结果 + @Override + public JSONObject getNullableResult(ResultSet rs, String columnName) throws SQLException { + String sqlJson = rs.getString(columnName); + if (null != sqlJson){ + return JSONObject.parseObject(sqlJson); + } + return null; + } + //根据列索引,获取可以为空的结果 + @Override + public JSONObject getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + String sqlJson = rs.getString(columnIndex); + if (null != sqlJson){ + return JSONObject.parseObject(sqlJson); + } + return null; + } + + @Override + public JSONObject getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { + String sqlJson = cs.getString(columnIndex); + if (null != sqlJson){ + return JSONObject.parseObject(sqlJson); + } + return null; + } +} \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml index 9fd7b6fa6..a79ab03a5 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml @@ -28,7 +28,6 @@ - @@ -49,7 +48,7 @@ SELECT * FROM( - SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_wei, cus_unit, remark + SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit, remark FROM sys_dishes_ingredient WHERE dishes_id = #{id} ) dishes @@ -149,9 +148,9 @@ - insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_wei, remark) values + insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark) values - (#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWei}, #{item.remark}) + (#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight}, #{item.remark}) diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml new file mode 100644 index 000000000..a0a0bb68c --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/stdiet-ui/src/api/custom/ingredient.js b/stdiet-ui/src/api/custom/ingredient.js index 6643a081e..19633cba3 100644 --- a/stdiet-ui/src/api/custom/ingredient.js +++ b/stdiet-ui/src/api/custom/ingredient.js @@ -4,7 +4,7 @@ import request from '@/utils/request' export function listIngredient(query) { const {recIds, notRecIds} = query; return request({ - url: '/custom/ingredient/list', + url: `/custom/ingredient/list?pageSize=${query.pageSize}&pageNum=${query.pageNum}`, method: 'post', data: { ...query, diff --git a/stdiet-ui/src/components/RecipesView/index.vue b/stdiet-ui/src/components/RecipesView/index.vue new file mode 100644 index 000000000..73be2526b --- /dev/null +++ b/stdiet-ui/src/components/RecipesView/index.vue @@ -0,0 +1,25 @@ + + + diff --git a/stdiet-ui/src/router/index.js b/stdiet-ui/src/router/index.js index a5e3c377f..44c8612d2 100644 --- a/stdiet-ui/src/router/index.js +++ b/stdiet-ui/src/router/index.js @@ -145,7 +145,7 @@ export const constantRoutes = [ hidden: true, children: [ { - path: "build/:cusId/:id(\\d+)", + path: "build/:cusId/:planId/:recipesId", component: resolve => require(["@/views/custom/recipesBuild"], resolve), name: "RecipiesBuild", diff --git a/stdiet-ui/src/store/index.js b/stdiet-ui/src/store/index.js index 53b8437ac..9f563d508 100644 --- a/stdiet-ui/src/store/index.js +++ b/stdiet-ui/src/store/index.js @@ -1,13 +1,15 @@ -import Vue from 'vue' -import Vuex from 'vuex' -import app from './modules/app' -import user from './modules/user' -import tagsView from './modules/tagsView' -import permission from './modules/permission' -import settings from './modules/settings' -import getters from './getters' +import Vue from "vue"; +import Vuex from "vuex"; +import app from "./modules/app"; +import user from "./modules/user"; +import tagsView from "./modules/tagsView"; +import permission from "./modules/permission"; +import settings from "./modules/settings"; +import recipes from "./modules/recipes"; -Vue.use(Vuex) +import getters from "./getters"; + +Vue.use(Vuex); const store = new Vuex.Store({ modules: { @@ -15,9 +17,10 @@ const store = new Vuex.Store({ user, tagsView, permission, - settings + settings, + recipes }, getters -}) +}); -export default store +export default store; diff --git a/stdiet-ui/src/store/modules/recipes.js b/stdiet-ui/src/store/modules/recipes.js new file mode 100644 index 000000000..781026630 --- /dev/null +++ b/stdiet-ui/src/store/modules/recipes.js @@ -0,0 +1,50 @@ +import { getOrder } from "@/api/custom/order"; +import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer"; +import { dealHealthy } from "@/utils/healthyData"; +import { getRecipesPlan } from "@/api/custom/recipesPlan"; + +const oriState = { + healthyData: {}, + healthyDataType: 0 +}; + +const mutations = { + setHealtyData(state, payload) { + state.healthyDataType = payload.healthyDataType; + state.healthyData = payload.healthyData; + }, + clean(state) { + console.log("clean"); + Object.keys(oriState).forEach(key => { + state[key] = oriState[key]; + }); + } +}; + +const actions = { + async init({ commit }, payload) { + const orderResult = await getOrder(payload.cusId); + if (!orderResult.data.cusId) { + throw new Error("未找到用户id"); + } + + const healthyDataResult = await getCustomerPhysicalSignsByCusId( + orderResult.data.cusId + ); + // 设置健康数据 + commit("setHealtyData", { + healthyDataType: healthyDataResult.data.type, + healthyData: dealHealthy(healthyDataResult.data.customerHealthy) + }); + } +}; + +const getters = {}; + +export default { + namespaced: true, + state: Object.assign({}, oriState), + mutations, + actions, + getters +}; diff --git a/stdiet-ui/src/views/custom/dishes/index.vue b/stdiet-ui/src/views/custom/dishes/index.vue index 9cf416028..9f9784738 100644 --- a/stdiet-ui/src/views/custom/dishes/index.vue +++ b/stdiet-ui/src/views/custom/dishes/index.vue @@ -258,7 +258,7 @@ step="0.5" :min="0.5" /> --> - + - diff --git a/stdiet-ui/src/views/custom/recipesBuild/HealthyView.vue b/stdiet-ui/src/views/custom/recipesBuild/HealthyView.vue index 70b3feb84..8157b4e57 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/HealthyView.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/HealthyView.vue @@ -181,12 +181,13 @@ export default { }, }; - diff --git a/stdiet-ui/src/views/custom/recipesBuild/TextInfo.vue b/stdiet-ui/src/views/custom/recipesBuild/TextInfo.vue index 56dae53ea..693014906 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/TextInfo.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/TextInfo.vue @@ -32,21 +32,21 @@ export default { props: ["title", "value", "extraclass"], }; - diff --git a/stdiet-ui/src/views/custom/recipesBuild/index.vue b/stdiet-ui/src/views/custom/recipesBuild/index.vue index 14e100aff..8871f8eb9 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/index.vue @@ -10,10 +10,11 @@ - diff --git a/stdiet-ui/src/views/custom/recipesPlan/build.vue b/stdiet-ui/src/views/custom/recipesPlan/build.vue deleted file mode 100644 index 7aba5fabc..000000000 --- a/stdiet-ui/src/views/custom/recipesPlan/build.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - diff --git a/stdiet-ui/src/views/custom/recipesPlan/index.vue b/stdiet-ui/src/views/custom/recipesPlan/index.vue index 0baf90b11..35675732b 100644 --- a/stdiet-ui/src/views/custom/recipesPlan/index.vue +++ b/stdiet-ui/src/views/custom/recipesPlan/index.vue @@ -198,7 +198,7 @@ type="text" icon="el-icon-edit" @click="handleBuild(scope.row)" - >制作食谱{{ `${scope.row.recipes_id ? "编辑" : "制作"}食谱` }} @@ -604,10 +604,20 @@ export default { } }, handleBuild(data) { - this.$router.push({ - name: "RecipiesBuild", - params: { id: data.id, cusId: data.orderId }, - }); + // const params = { id: data.id, cusId: data.orderId }; + let path = `/recipes/build/${data.orderId}/${data.id}`; + if (data.recipes_id) { + // params.recipesId = data.recipes_id; + path += `/${data.recipes_id}`; + } + // test + // params.recipesId = "61"; + path += '/61'; + // this.$router.push({ + // name: "build", + // params, + // }); + this.$router.push(path); }, }, };