From 27bf41b006edf7e5378c90e9682b137d9985af48 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Tue, 15 Dec 2020 21:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A3=9F=E6=9D=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/ry_20200920.sql | 4 - .../custom/SysIngredientController.java | 103 +++++ .../stdiet/custom/domain/SysIngredient.java | 197 ++++++++ .../custom/mapper/SysIngredientMapper.java | 61 +++ .../custom/service/ISysIngredientService.java | 61 +++ .../impl/SysIngredientServiceImpl.java | 96 ++++ .../mapper/custom/SysIngredientMapper.xml | 121 +++++ stdiet-ui/src/api/custom/ingredient.js | 53 +++ stdiet-ui/src/components/Breadcrumb/index.vue | 7 +- .../src/views/custom/ingredient/index.vue | 424 ++++++++++++++++++ stdiet-ui/src/views/custom/order/index.vue | 2 + 11 files changed, 1123 insertions(+), 6 deletions(-) create mode 100644 stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java create mode 100644 stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml create mode 100644 stdiet-ui/src/api/custom/ingredient.js create mode 100644 stdiet-ui/src/views/custom/ingredient/index.vue diff --git a/sql/ry_20200920.sql b/sql/ry_20200920.sql index b67a569d0..8d6275017 100644 --- a/sql/ry_20200920.sql +++ b/sql/ry_20200920.sql @@ -826,10 +826,6 @@ create table sys_ingredient( protein_ratio decimal(10,3) comment '蛋白质比例', fat_ratio decimal(10,3) comment '脂肪比例', carbon_ratio decimal(10,3) comment '碳水比例', - protein_mass_ratio decimal(10,3) comment '蛋白质质量比', - fat_mass decimal(10,3) comment '脂肪质量', - carbon_mass decimal(10,3) comment '碳水质量', - heat decimal(10,3) comment '热量', remark varchar(500) comment '备注', area varchar(20) comment '地域', not_rec varchar(500) comment '忌口', 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 new file mode 100644 index 000000000..f293a54b8 --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysIngredientController.java @@ -0,0 +1,103 @@ +package com.stdiet.web.controller.custom; + +import java.util.List; +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 com.stdiet.common.annotation.Log; +import com.stdiet.common.core.controller.BaseController; +import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.enums.BusinessType; +import com.stdiet.custom.domain.SysIngredient; +import com.stdiet.custom.service.ISysIngredientService; +import com.stdiet.common.utils.poi.ExcelUtil; +import com.stdiet.common.core.page.TableDataInfo; + +/** + * 食材Controller + * + * @author wonder + * @date 2020-12-15 + */ +@RestController +@RequestMapping("/custom/ingredient") +public class SysIngredientController extends BaseController +{ + @Autowired + private ISysIngredientService sysIngredientService; + + /** + * 查询食材列表 + */ + @PreAuthorize("@ss.hasPermi('custom:ingredient:list')") + @GetMapping("/list") + public TableDataInfo list(SysIngredient sysIngredient) + { + startPage(); + List list = sysIngredientService.selectSysIngredientList(sysIngredient); + return getDataTable(list); + } + + /** + * 导出食材列表 + */ + @PreAuthorize("@ss.hasPermi('custom:ingredient:export')") + @Log(title = "食材", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysIngredient sysIngredient) + { + List list = sysIngredientService.selectSysIngredientList(sysIngredient); + ExcelUtil util = new ExcelUtil(SysIngredient.class); + return util.exportExcel(list, "ingredient"); + } + + /** + * 获取食材详细信息 + */ + @PreAuthorize("@ss.hasPermi('custom:ingredient:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(sysIngredientService.selectSysIngredientById(id)); + } + + /** + * 新增食材 + */ + @PreAuthorize("@ss.hasPermi('custom:ingredient:add')") + @Log(title = "食材", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysIngredient sysIngredient) + { + return toAjax(sysIngredientService.insertSysIngredient(sysIngredient)); + } + + /** + * 修改食材 + */ + @PreAuthorize("@ss.hasPermi('custom:ingredient:edit')") + @Log(title = "食材", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysIngredient sysIngredient) + { + return toAjax(sysIngredientService.updateSysIngredient(sysIngredient)); + } + + /** + * 删除食材 + */ + @PreAuthorize("@ss.hasPermi('custom:ingredient:remove')") + @Log(title = "食材", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sysIngredientService.deleteSysIngredientByIds(ids)); + } +} \ 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 new file mode 100644 index 000000000..77494dfc4 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java @@ -0,0 +1,197 @@ +package com.stdiet.custom.domain; + +import java.math.BigDecimal; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.stdiet.common.annotation.Excel; +import com.stdiet.common.core.domain.BaseEntity; + +/** + * 食材对象 sys_ingredient + * + * @author wonder + * @date 2020-12-15 + */ +public class SysIngredient extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 食材名称 */ + @Excel(name = "食材名称") + private String name; + + /** 食材类别 */ + @Excel(name = "食材类别") + private String type; + + /** 推荐分量估算 */ + @Excel(name = "推荐分量估算") + private Long recEstimation; + + /** 推荐分量估算单位id */ + @Excel(name = "推荐分量估算单位id") + private Long recEstUnit; + + /** 推荐分量 */ + @Excel(name = "推荐分量") + private Long recPortion; + + /** 蛋白质比例 */ + @Excel(name = "蛋白质比例") + private BigDecimal proteinRatio; + + /** 脂肪比例 */ + @Excel(name = "脂肪比例") + private BigDecimal fatRatio; + + /** 碳水比例 */ + @Excel(name = "碳水比例") + private BigDecimal carbonRatio; + + /** 地域 */ + @Excel(name = "地域") + private String area; + + /** 忌口 */ + @Excel(name = "忌口") + private String notRec; + + /** 推荐 */ + @Excel(name = "推荐") + private String recommend; + + public void setId(Long id) + { + this.id = id; + } + + 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 setRecEstimation(Long recEstimation) + { + this.recEstimation = recEstimation; + } + + public Long getRecEstimation() + { + return recEstimation; + } + public void setRecEstUnit(Long recEstUnit) + { + this.recEstUnit = recEstUnit; + } + + public Long getRecEstUnit() + { + return recEstUnit; + } + public void setRecPortion(Long recPortion) + { + this.recPortion = recPortion; + } + + public Long getRecPortion() + { + return recPortion; + } + public void setProteinRatio(BigDecimal proteinRatio) + { + this.proteinRatio = proteinRatio; + } + + public BigDecimal getProteinRatio() + { + return proteinRatio; + } + public void setFatRatio(BigDecimal fatRatio) + { + this.fatRatio = fatRatio; + } + + public BigDecimal getFatRatio() + { + return fatRatio; + } + public void setCarbonRatio(BigDecimal carbonRatio) + { + this.carbonRatio = carbonRatio; + } + + public BigDecimal getCarbonRatio() + { + return carbonRatio; + } + public void setArea(String area) + { + this.area = area; + } + + public String getArea() + { + return area; + } + public void setNotRec(String notRec) + { + this.notRec = notRec; + } + + public String getNotRec() + { + return notRec; + } + public void setRecommend(String recommend) + { + this.recommend = recommend; + } + + public String getRecommend() + { + return recommend; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .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()) + .append("remark", getRemark()) + .append("area", getArea()) + .append("notRec", getNotRec()) + .append("recommend", getRecommend()) + .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/mapper/SysIngredientMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java new file mode 100644 index 000000000..4a8ee6f04 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java @@ -0,0 +1,61 @@ +package com.stdiet.custom.mapper; + +import java.util.List; +import com.stdiet.custom.domain.SysIngredient; + +/** + * 食材Mapper接口 + * + * @author wonder + * @date 2020-12-15 + */ +public interface SysIngredientMapper +{ + /** + * 查询食材 + * + * @param id 食材ID + * @return 食材 + */ + public SysIngredient selectSysIngredientById(Long id); + + /** + * 查询食材列表 + * + * @param sysIngredient 食材 + * @return 食材集合 + */ + public List selectSysIngredientList(SysIngredient sysIngredient); + + /** + * 新增食材 + * + * @param sysIngredient 食材 + * @return 结果 + */ + public int insertSysIngredient(SysIngredient sysIngredient); + + /** + * 修改食材 + * + * @param sysIngredient 食材 + * @return 结果 + */ + public int updateSysIngredient(SysIngredient sysIngredient); + + /** + * 删除食材 + * + * @param id 食材ID + * @return 结果 + */ + public int deleteSysIngredientById(Long id); + + /** + * 批量删除食材 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysIngredientByIds(Long[] ids); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java new file mode 100644 index 000000000..ab63c4ace --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysIngredientService.java @@ -0,0 +1,61 @@ +package com.stdiet.custom.service; + +import java.util.List; +import com.stdiet.custom.domain.SysIngredient; + +/** + * 食材Service接口 + * + * @author wonder + * @date 2020-12-15 + */ +public interface ISysIngredientService +{ + /** + * 查询食材 + * + * @param id 食材ID + * @return 食材 + */ + public SysIngredient selectSysIngredientById(Long id); + + /** + * 查询食材列表 + * + * @param sysIngredient 食材 + * @return 食材集合 + */ + public List selectSysIngredientList(SysIngredient sysIngredient); + + /** + * 新增食材 + * + * @param sysIngredient 食材 + * @return 结果 + */ + public int insertSysIngredient(SysIngredient sysIngredient); + + /** + * 修改食材 + * + * @param sysIngredient 食材 + * @return 结果 + */ + public int updateSysIngredient(SysIngredient sysIngredient); + + /** + * 批量删除食材 + * + * @param ids 需要删除的食材ID + * @return 结果 + */ + public int deleteSysIngredientByIds(Long[] ids); + + /** + * 删除食材信息 + * + * @param id 食材ID + * @return 结果 + */ + public int deleteSysIngredientById(Long id); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java new file mode 100644 index 000000000..b8f3ae61d --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java @@ -0,0 +1,96 @@ +package com.stdiet.custom.service.impl; + +import java.util.List; +import com.stdiet.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.stdiet.custom.mapper.SysIngredientMapper; +import com.stdiet.custom.domain.SysIngredient; +import com.stdiet.custom.service.ISysIngredientService; + +/** + * 食材Service业务层处理 + * + * @author wonder + * @date 2020-12-15 + */ +@Service +public class SysIngredientServiceImpl implements ISysIngredientService +{ + @Autowired + private SysIngredientMapper sysIngredientMapper; + + /** + * 查询食材 + * + * @param id 食材ID + * @return 食材 + */ + @Override + public SysIngredient selectSysIngredientById(Long id) + { + return sysIngredientMapper.selectSysIngredientById(id); + } + + /** + * 查询食材列表 + * + * @param sysIngredient 食材 + * @return 食材 + */ + @Override + public List selectSysIngredientList(SysIngredient sysIngredient) + { + return sysIngredientMapper.selectSysIngredientList(sysIngredient); + } + + /** + * 新增食材 + * + * @param sysIngredient 食材 + * @return 结果 + */ + @Override + public int insertSysIngredient(SysIngredient sysIngredient) + { + sysIngredient.setCreateTime(DateUtils.getNowDate()); + return sysIngredientMapper.insertSysIngredient(sysIngredient); + } + + /** + * 修改食材 + * + * @param sysIngredient 食材 + * @return 结果 + */ + @Override + public int updateSysIngredient(SysIngredient sysIngredient) + { + sysIngredient.setUpdateTime(DateUtils.getNowDate()); + return sysIngredientMapper.updateSysIngredient(sysIngredient); + } + + /** + * 批量删除食材 + * + * @param ids 需要删除的食材ID + * @return 结果 + */ + @Override + public int deleteSysIngredientByIds(Long[] ids) + { + return sysIngredientMapper.deleteSysIngredientByIds(ids); + } + + /** + * 删除食材信息 + * + * @param id 食材ID + * @return 结果 + */ + @Override + public int deleteSysIngredientById(Long id) + { + return sysIngredientMapper.deleteSysIngredientById(id); + } +} \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml new file mode 100644 index 000000000..890f60ccc --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, name, type, rec_estimation, rec_est_unit, rec_portion, protein_ratio, fat_ratio, carbon_ratio, remark, area, not_rec, recommend, create_by, create_time, update_by, update_time from sys_ingredient + + + + + + + + insert into sys_ingredient + + name, + type, + rec_estimation, + rec_est_unit, + rec_portion, + protein_ratio, + fat_ratio, + carbon_ratio, + remark, + area, + not_rec, + recommend, + create_by, + create_time, + update_by, + update_time, + + + #{name}, + #{type}, + #{recEstimation}, + #{recEstUnit}, + #{recPortion}, + #{proteinRatio}, + #{fatRatio}, + #{carbonRatio}, + #{remark}, + #{area}, + #{notRec}, + #{recommend}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update sys_ingredient + + name = #{name}, + type = #{type}, + rec_estimation = #{recEstimation}, + rec_est_unit = #{recEstUnit}, + rec_portion = #{recPortion}, + protein_ratio = #{proteinRatio}, + fat_ratio = #{fatRatio}, + carbon_ratio = #{carbonRatio}, + remark = #{remark}, + area = #{area}, + not_rec = #{notRec}, + recommend = #{recommend}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from sys_ingredient where id = #{id} + + + + delete from sys_ingredient where id in + + #{id} + + + + \ No newline at end of file diff --git a/stdiet-ui/src/api/custom/ingredient.js b/stdiet-ui/src/api/custom/ingredient.js new file mode 100644 index 000000000..5d7c4ab02 --- /dev/null +++ b/stdiet-ui/src/api/custom/ingredient.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 查询食材列表 +export function listIngredient(query) { + return request({ + url: '/custom/ingredient/list', + method: 'get', + params: query + }) +} + +// 查询食材详细 +export function getIngredient(id) { + return request({ + url: '/custom/ingredient/' + id, + method: 'get' + }) +} + +// 新增食材 +export function addIngredient(data) { + return request({ + url: '/custom/ingredient', + method: 'post', + data: data + }) +} + +// 修改食材 +export function updateIngredient(data) { + return request({ + url: '/custom/ingredient', + method: 'put', + data: data + }) +} + +// 删除食材 +export function delIngredient(id) { + return request({ + url: '/custom/ingredient/' + id, + method: 'delete' + }) +} + +// 导出食材 +export function exportIngredient(query) { + return request({ + url: '/custom/ingredient/export', + method: 'get', + params: query + }) +} diff --git a/stdiet-ui/src/components/Breadcrumb/index.vue b/stdiet-ui/src/components/Breadcrumb/index.vue index 97603c4f0..46cd0e8a4 100644 --- a/stdiet-ui/src/components/Breadcrumb/index.vue +++ b/stdiet-ui/src/components/Breadcrumb/index.vue @@ -1,7 +1,7 @@