新增食材管理

This commit is contained in:
huangdeliang
2020-12-15 21:11:45 +08:00
parent a3fc7d7da7
commit 27bf41b006
11 changed files with 1123 additions and 6 deletions

View File

@ -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();
}
}

View File

@ -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<SysIngredient> 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);
}

View File

@ -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<SysIngredient> 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);
}

View File

@ -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<SysIngredient> 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);
}
}

View File

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stdiet.custom.mapper.SysIngredientMapper">
<resultMap type="SysIngredient" id="SysIngredientResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="type" column="type" />
<result property="recEstimation" column="rec_estimation" />
<result property="recEstUnit" column="rec_est_unit" />
<result property="recPortion" column="rec_portion" />
<result property="proteinRatio" column="protein_ratio" />
<result property="fatRatio" column="fat_ratio" />
<result property="carbonRatio" column="carbon_ratio" />
<result property="remark" column="remark" />
<result property="area" column="area" />
<result property="notRec" column="not_rec" />
<result property="recommend" column="recommend" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSysIngredientVo">
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
</sql>
<select id="selectSysIngredientList" parameterType="SysIngredient" resultMap="SysIngredientResult">
<include refid="selectSysIngredientVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="area != null and area != ''"> and area = #{area}</if>
<if test="notRec != null and notRec != ''"> and not_rec like concat('%', #{notRec}, '%')</if>
<if test="recommend != null and recommend != ''"> and recommend like concat('%', #{recommend}, '%')</if>
</where>
</select>
<select id="selectSysIngredientById" parameterType="Long" resultMap="SysIngredientResult">
<include refid="selectSysIngredientVo"/>
where id = #{id}
</select>
<insert id="insertSysIngredient" parameterType="SysIngredient" useGeneratedKeys="true" keyProperty="id">
insert into sys_ingredient
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="type != null">type,</if>
<if test="recEstimation != null">rec_estimation,</if>
<if test="recEstUnit != null">rec_est_unit,</if>
<if test="recPortion != null">rec_portion,</if>
<if test="proteinRatio != null">protein_ratio,</if>
<if test="fatRatio != null">fat_ratio,</if>
<if test="carbonRatio != null">carbon_ratio,</if>
<if test="remark != null">remark,</if>
<if test="area != null">area,</if>
<if test="notRec != null">not_rec,</if>
<if test="recommend != null">recommend,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="type != null">#{type},</if>
<if test="recEstimation != null">#{recEstimation},</if>
<if test="recEstUnit != null">#{recEstUnit},</if>
<if test="recPortion != null">#{recPortion},</if>
<if test="proteinRatio != null">#{proteinRatio},</if>
<if test="fatRatio != null">#{fatRatio},</if>
<if test="carbonRatio != null">#{carbonRatio},</if>
<if test="remark != null">#{remark},</if>
<if test="area != null">#{area},</if>
<if test="notRec != null">#{notRec},</if>
<if test="recommend != null">#{recommend},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSysIngredient" parameterType="SysIngredient">
update sys_ingredient
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="type != null">type = #{type},</if>
<if test="recEstimation != null">rec_estimation = #{recEstimation},</if>
<if test="recEstUnit != null">rec_est_unit = #{recEstUnit},</if>
<if test="recPortion != null">rec_portion = #{recPortion},</if>
<if test="proteinRatio != null">protein_ratio = #{proteinRatio},</if>
<if test="fatRatio != null">fat_ratio = #{fatRatio},</if>
<if test="carbonRatio != null">carbon_ratio = #{carbonRatio},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="area != null">area = #{area},</if>
<if test="notRec != null">not_rec = #{notRec},</if>
<if test="recommend != null">recommend = #{recommend},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysIngredientById" parameterType="Long">
delete from sys_ingredient where id = #{id}
</delete>
<delete id="deleteSysIngredientByIds" parameterType="String">
delete from sys_ingredient where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>