This commit is contained in:
huangdeliang
2020-12-29 10:07:19 +08:00
parent fa5264b908
commit eeaa3d36e9
15 changed files with 952 additions and 18 deletions

View File

@ -0,0 +1,82 @@
<?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="methods" column="methods" />
<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="selectSysDishesVo">
select id, name, type, methods, create_by, create_time, update_by, update_time 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 type = #{type}</if>
</where>
</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="methods != null">methods,</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="methods != null">#{methods},</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="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="methods != null">methods = #{methods},</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="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>
</mapper>

View File

@ -22,26 +22,79 @@
</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
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)
</sql>
<sql id="selectSysIngredientByPhyVo">
SELECT * FROM sys_ingredient igd
RIGHT JOIN(
SELECT * FROM(
SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_rec
<where>
<if test="recIds != null">
physical_signs_id in
<foreach collection="recIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
) 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
<where>
<if test="notRecIds != null">
physical_signs_id in
<foreach collection="notRecIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
) 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)
</sql>
<select id="selectSysIngredientList" parameterType="SysIngredient" resultMap="SysIngredientResult">
<include refid="selectSysIngredientVo"/>
<choose>
<when test="recIds == null and notRecIds == null">
<include refid="selectSysIngredientVo"/>
</when>
<otherwise>
<include refid="selectSysIngredientByPhyVo">
<property name="recIds" value="#{recIds}"/>
<property name="notRecIds" value="#{notRecIds}"/>
</include>
</otherwise>
</choose>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>