121 lines
5.5 KiB
XML
121 lines
5.5 KiB
XML
<?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="proteinRatio" column="protein_ratio" />
|
|
<result property="fatRatio" column="fat_ratio" />
|
|
<result property="carbonRatio" column="carbon_ratio" />
|
|
<result property="area" column="area" />
|
|
<result property="remark" column="remark" />
|
|
<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, protein_ratio, fat_ratio, carbon_ratio, area, remark, 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>
|
|
</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="proteinRatio != null">protein_ratio,</if>
|
|
<if test="fatRatio != null">fat_ratio,</if>
|
|
<if test="carbonRatio != null">carbon_ratio,</if>
|
|
<if test="area != null">area,</if>
|
|
<if test="remark != null">remark,</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="proteinRatio != null">#{proteinRatio},</if>
|
|
<if test="fatRatio != null">#{fatRatio},</if>
|
|
<if test="carbonRatio != null">#{carbonRatio},</if>
|
|
<if test="area != null">#{area},</if>
|
|
<if test="remark != null">#{remark},</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>
|
|
|
|
<insert id="batchIngredientRec" >
|
|
insert into sys_ingredient_rec(ingredient_id, rec_id) values
|
|
<foreach collection="list" separator="," item="item" index="index">
|
|
(#{item.ingredientId},#{item.recommandId})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<insert id="batchIngredientNotRec" >
|
|
insert into sys_ingredient_not_rec(ingredient_id, not_rec_id) values
|
|
<foreach collection="list" separator="," item="item" index="index">
|
|
(#{item.ingredientId},#{item.notRecommandId})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<delete id="deleteIngredentRecByIngredientId" parameterType="Long">
|
|
delete from sys_ingredient_rec where ingredient_id=#{ingredientId}
|
|
</delete>
|
|
|
|
<delete id="deleteIngredentNotRecByIngredientId" parameterType="Long">
|
|
delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId}
|
|
</delete>
|
|
|
|
<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="proteinRatio != null">protein_ratio = #{proteinRatio},</if>
|
|
<if test="fatRatio != null">fat_ratio = #{fatRatio},</if>
|
|
<if test="carbonRatio != null">carbon_ratio = #{carbonRatio},</if>
|
|
<if test="area != null">area = #{area},</if>
|
|
<if test="remark != null">remark = #{remark},</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> |