158 lines
7.1 KiB
XML
158 lines
7.1 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.SysDishesMapper">
|
|
|
|
<resultMap type="SysDishes" id="SysDishesResult">
|
|
<result property="id" column="id" />
|
|
<result property="name" column="name" />
|
|
<result property="type" column="type" />
|
|
<result property="isMain" column="is_main" />
|
|
<result property="methods" column="methods" />
|
|
<result property="reviewStatus" column="review_status" />
|
|
<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>
|
|
|
|
<resultMap type="SysDishesIngredient" id="SysDishesIngredientResult">
|
|
<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="rec" column="rec" />
|
|
<result property="notRec" column="not_rec" />
|
|
<result property="cusWeight" column="cus_weight" />
|
|
<result property="cusUnit" column="cus_unit" />
|
|
<result property="weight" column="weight" />
|
|
</resultMap>
|
|
|
|
<sql id="selectSysDishesVo">
|
|
select id, name, type, is_main, methods, create_by, create_time, update_by, update_time, review_status from sys_dishes
|
|
</sql>
|
|
|
|
<select id="selectSysDishesList" parameterType="SysDishes" resultMap="SysDishesResult">
|
|
<include refid="selectSysDishesVo"/>
|
|
<where>
|
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
|
<if test="type != null and type != ''"> and FIND_IN_SET(#{type}, type)</if>
|
|
<if test="reviewStatus != null and type != ''"> and review_status = #{reviewStatus}</if>
|
|
<if test="isMain != null and type != ''"> and is_main = #{isMain}</if>
|
|
</where>
|
|
order by id desc
|
|
</select>
|
|
|
|
<sql id="selectSysIngreditentsByIdVo">
|
|
SELECT * FROM(
|
|
SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit, remark
|
|
FROM sys_dishes_ingredient
|
|
WHERE dishes_id = #{id}
|
|
) dishes
|
|
LEFT JOIN (
|
|
SELECT id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, not_rec, rec
|
|
FROM sys_ingredient igd
|
|
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
|
|
) 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
|
|
) rec JOIN sys_physical_signs phy USING(id)
|
|
GROUP BY id
|
|
) recT USING(id)
|
|
) ing USING(id)
|
|
</sql>
|
|
|
|
<select id="selectSysIngreditentsById" parameterType="Long" resultMap="SysDishesIngredientResult">
|
|
<include refid="selectSysIngreditentsByIdVo" >
|
|
<property name="id" value="#{id}"/>
|
|
</include>
|
|
</select>
|
|
|
|
<select id="selectSysDishesById" parameterType="Long" resultMap="SysDishesResult">
|
|
<include refid="selectSysDishesVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertSysDishes" parameterType="SysDishes" useGeneratedKeys="true" keyProperty="id">
|
|
insert into sys_dishes
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="name != null">name,</if>
|
|
<if test="type != null">type,</if>
|
|
<if test="isMain != null">is_main,</if>
|
|
<if test="methods != null">methods,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="reviewStatus != null">review_status,</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="isMain != null">#{isMain},</if>
|
|
<if test="methods != null">#{methods},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="reviewStatus != null">#{reviewStatus},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateSysDishes" parameterType="SysDishes">
|
|
update sys_dishes
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="name != null">name = #{name},</if>
|
|
<if test="type != null">type = #{type},</if>
|
|
<if test="isMain != null">is_main = #{isMain},</if>
|
|
<if test="methods != null">methods = #{methods},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="reviewStatus != null">review_status = #{reviewStatus},</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="deleteSysDishesById" parameterType="Long">
|
|
delete from sys_dishes where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteSysDishesByIds" parameterType="String">
|
|
delete from sys_dishes where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deleteIngredientById" parameterType="Long">
|
|
delete from sys_dishes_ingredient where dishes_id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteIngredientByIds" parameterType="String">
|
|
delete from sys_dishes_ingredient where dishes_id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<insert id="bashInsertDishesIngredent">
|
|
insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark) values
|
|
<foreach collection="list" separator="," item="item" index="index">
|
|
(#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight}, #{item.remark})
|
|
</foreach>
|
|
</insert>
|
|
|
|
</mapper> |