diff --git a/stdiet-admin/src/main/filters/dev/application.yml b/stdiet-admin/src/main/filters/dev/application.yml index ea066bf81..1cc260e8a 100644 --- a/stdiet-admin/src/main/filters/dev/application.yml +++ b/stdiet-admin/src/main/filters/dev/application.yml @@ -83,7 +83,7 @@ spring: # 主库数据源 master: url: jdbc:mysql://localhost:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - password: Ttj4fAHU + password: S6QAUjVMFwWe username: root slave: # 从数据源开关/默认关闭 diff --git a/stdiet-admin/src/main/filters/local/application.yml b/stdiet-admin/src/main/filters/local/application.yml index b62d36752..3c7cc4ede 100644 --- a/stdiet-admin/src/main/filters/local/application.yml +++ b/stdiet-admin/src/main/filters/local/application.yml @@ -83,7 +83,7 @@ spring: # 主库数据源 master: url: jdbc:mysql://47.115.23.82:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - password: Ttj4fAHU + password: S6QAUjVMFwWe username: root slave: # 从数据源开关/默认关闭 diff --git a/stdiet-admin/src/main/filters/prod/application.yml b/stdiet-admin/src/main/filters/prod/application.yml index c53c79d8a..9c4701cca 100644 --- a/stdiet-admin/src/main/filters/prod/application.yml +++ b/stdiet-admin/src/main/filters/prod/application.yml @@ -83,7 +83,7 @@ spring: # 主库数据源 master: url: jdbc:mysql://localhost:3306/stdiet?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - password: Ttj4fAHU + password: S6QAUjVMFwWe username: root slave: # 从数据源开关/默认关闭 diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysDishesController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysDishesController.java new file mode 100644 index 000000000..6366a249c --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysDishesController.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.SysDishes; +import com.stdiet.custom.service.ISysDishesService; +import com.stdiet.common.utils.poi.ExcelUtil; +import com.stdiet.common.core.page.TableDataInfo; + +/** + * 菜品Controller + * + * @author wonder + * @date 2020-12-28 + */ +@RestController +@RequestMapping("/custom/dishes") +public class SysDishesController extends BaseController +{ + @Autowired + private ISysDishesService sysDishesService; + + /** + * 查询菜品列表 + */ + @PreAuthorize("@ss.hasPermi('custom:dishes:list')") + @GetMapping("/list") + public TableDataInfo list(SysDishes sysDishes) + { + startPage(); + List list = sysDishesService.selectSysDishesList(sysDishes); + return getDataTable(list); + } + + /** + * 导出菜品列表 + */ + @PreAuthorize("@ss.hasPermi('custom:dishes:export')") + @Log(title = "菜品", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysDishes sysDishes) + { + List list = sysDishesService.selectSysDishesList(sysDishes); + ExcelUtil util = new ExcelUtil(SysDishes.class); + return util.exportExcel(list, "dishes"); + } + + /** + * 获取菜品详细信息 + */ + @PreAuthorize("@ss.hasPermi('custom:dishes:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(sysDishesService.selectSysDishesById(id)); + } + + /** + * 新增菜品 + */ + @PreAuthorize("@ss.hasPermi('custom:dishes:add')") + @Log(title = "菜品", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysDishes sysDishes) + { + return toAjax(sysDishesService.insertSysDishes(sysDishes)); + } + + /** + * 修改菜品 + */ + @PreAuthorize("@ss.hasPermi('custom:dishes:edit')") + @Log(title = "菜品", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysDishes sysDishes) + { + return toAjax(sysDishesService.updateSysDishes(sysDishes)); + } + + /** + * 删除菜品 + */ + @PreAuthorize("@ss.hasPermi('custom:dishes:remove')") + @Log(title = "菜品", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sysDishesService.deleteSysDishesByIds(ids)); + } +} \ No newline at end of file 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 f293a54b8..a4ec6ab63 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 @@ -37,8 +37,8 @@ public class SysIngredientController extends BaseController * 查询食材列表 */ @PreAuthorize("@ss.hasPermi('custom:ingredient:list')") - @GetMapping("/list") - public TableDataInfo list(SysIngredient sysIngredient) + @PostMapping("/list") + public TableDataInfo list(@RequestBody SysIngredient sysIngredient) { startPage(); List list = sysIngredientService.selectSysIngredientList(sysIngredient); 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 new file mode 100644 index 000000000..cd23e764a --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysDishes.java @@ -0,0 +1,83 @@ +package com.stdiet.custom.domain; + +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_dishes + * + * @author wonder + * @date 2020-12-28 + */ +public class SysDishes 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 String methods; + + 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 setMethods(String methods) + { + this.methods = methods; + } + + public String getMethods() + { + return methods; + } + + @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/mapper/SysDishesMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysDishesMapper.java new file mode 100644 index 000000000..e24d49a5b --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysDishesMapper.java @@ -0,0 +1,61 @@ +package com.stdiet.custom.mapper; + +import java.util.List; +import com.stdiet.custom.domain.SysDishes; + +/** + * 菜品Mapper接口 + * + * @author wonder + * @date 2020-12-28 + */ +public interface SysDishesMapper +{ + /** + * 查询菜品 + * + * @param id 菜品ID + * @return 菜品 + */ + public SysDishes selectSysDishesById(Long id); + + /** + * 查询菜品列表 + * + * @param sysDishes 菜品 + * @return 菜品集合 + */ + public List selectSysDishesList(SysDishes sysDishes); + + /** + * 新增菜品 + * + * @param sysDishes 菜品 + * @return 结果 + */ + public int insertSysDishes(SysDishes sysDishes); + + /** + * 修改菜品 + * + * @param sysDishes 菜品 + * @return 结果 + */ + public int updateSysDishes(SysDishes sysDishes); + + /** + * 删除菜品 + * + * @param id 菜品ID + * @return 结果 + */ + public int deleteSysDishesById(Long id); + + /** + * 批量删除菜品 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysDishesByIds(Long[] ids); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysDishesService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysDishesService.java new file mode 100644 index 000000000..c3def4487 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysDishesService.java @@ -0,0 +1,61 @@ +package com.stdiet.custom.service; + +import java.util.List; +import com.stdiet.custom.domain.SysDishes; + +/** + * 菜品Service接口 + * + * @author wonder + * @date 2020-12-28 + */ +public interface ISysDishesService +{ + /** + * 查询菜品 + * + * @param id 菜品ID + * @return 菜品 + */ + public SysDishes selectSysDishesById(Long id); + + /** + * 查询菜品列表 + * + * @param sysDishes 菜品 + * @return 菜品集合 + */ + public List selectSysDishesList(SysDishes sysDishes); + + /** + * 新增菜品 + * + * @param sysDishes 菜品 + * @return 结果 + */ + public int insertSysDishes(SysDishes sysDishes); + + /** + * 修改菜品 + * + * @param sysDishes 菜品 + * @return 结果 + */ + public int updateSysDishes(SysDishes sysDishes); + + /** + * 批量删除菜品 + * + * @param ids 需要删除的菜品ID + * @return 结果 + */ + public int deleteSysDishesByIds(Long[] ids); + + /** + * 删除菜品信息 + * + * @param id 菜品ID + * @return 结果 + */ + public int deleteSysDishesById(Long id); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysDishesServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysDishesServiceImpl.java new file mode 100644 index 000000000..bcdcbbd2a --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysDishesServiceImpl.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.SysDishesMapper; +import com.stdiet.custom.domain.SysDishes; +import com.stdiet.custom.service.ISysDishesService; + +/** + * 菜品Service业务层处理 + * + * @author wonder + * @date 2020-12-28 + */ +@Service +public class SysDishesServiceImpl implements ISysDishesService +{ + @Autowired + private SysDishesMapper sysDishesMapper; + + /** + * 查询菜品 + * + * @param id 菜品ID + * @return 菜品 + */ + @Override + public SysDishes selectSysDishesById(Long id) + { + return sysDishesMapper.selectSysDishesById(id); + } + + /** + * 查询菜品列表 + * + * @param sysDishes 菜品 + * @return 菜品 + */ + @Override + public List selectSysDishesList(SysDishes sysDishes) + { + return sysDishesMapper.selectSysDishesList(sysDishes); + } + + /** + * 新增菜品 + * + * @param sysDishes 菜品 + * @return 结果 + */ + @Override + public int insertSysDishes(SysDishes sysDishes) + { + sysDishes.setCreateTime(DateUtils.getNowDate()); + return sysDishesMapper.insertSysDishes(sysDishes); + } + + /** + * 修改菜品 + * + * @param sysDishes 菜品 + * @return 结果 + */ + @Override + public int updateSysDishes(SysDishes sysDishes) + { + sysDishes.setUpdateTime(DateUtils.getNowDate()); + return sysDishesMapper.updateSysDishes(sysDishes); + } + + /** + * 批量删除菜品 + * + * @param ids 需要删除的菜品ID + * @return 结果 + */ + @Override + public int deleteSysDishesByIds(Long[] ids) + { + return sysDishesMapper.deleteSysDishesByIds(ids); + } + + /** + * 删除菜品信息 + * + * @param id 菜品ID + * @return 结果 + */ + @Override + public int deleteSysDishesById(Long id) + { + return sysDishesMapper.deleteSysDishesById(id); + } +} \ 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 new file mode 100644 index 000000000..32b0dce05 --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysDishesMapper.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + select id, name, type, methods, create_by, create_time, update_by, update_time from sys_dishes + + + + + + + + insert into sys_dishes + + name, + type, + methods, + create_by, + create_time, + update_by, + update_time, + + + #{name}, + #{type}, + #{methods}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update sys_dishes + + name = #{name}, + type = #{type}, + methods = #{methods}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from sys_dishes where id = #{id} + + + + delete from sys_dishes where id in + + #{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 index 214d137ae..cd7292331 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml @@ -22,26 +22,79 @@ --- select id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, remark, create_by, create_time, update_by, update_time from sys_ingredient SELECT * FROM sys_ingredient igd - LEFT JOIN ( + LEFT JOIN ( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM( - SELECT physical_signs_id as id, ingredient_id - FROM sys_ingredient_not_rec + SELECT physical_signs_id as id, ingredient_id + FROM sys_ingredient_not_rec ) notRec JOIN sys_physical_signs phy USING(id) GROUP BY id - ) notRecT USING(id) - LEFT JOIN ( + ) notRecT USING(id) + LEFT JOIN ( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM( - SELECT physical_signs_id as id, ingredient_id - FROM sys_ingredient_rec + SELECT physical_signs_id as id, ingredient_id + FROM sys_ingredient_rec ) rec JOIN sys_physical_signs phy USING(id) - GROUP BY id) recT - USING(id) + GROUP BY id + ) recT USING(id) + + + + SELECT * FROM sys_ingredient igd + RIGHT JOIN( + SELECT * FROM( + SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_rec + + + physical_signs_id in + + #{item} + + + + ) recId + LEFT JOIN ( + SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM( + SELECT physical_signs_id as id, ingredient_id + FROM sys_ingredient_rec + ) rec JOIN sys_physical_signs phy USING(id) + GROUP BY id + ) recM USING(id) + INNER JOIN ( + SELECT * FROM( + SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_not_rec + + + physical_signs_id in + + #{item} + + + + ) notRecId + LEFT JOIN ( + SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM( + SELECT physical_signs_id as id, ingredient_id + FROM sys_ingredient_not_rec + ) notRec JOIN sys_physical_signs phy USING(id) + GROUP BY id + ) notRecM USING(id) + ) notRecT USING(id) + ) recT USING(id)