126 lines
6.7 KiB
XML
126 lines
6.7 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.bonus.canteen.core.cook.mapper.CookRecipeMapper">
|
|
<resultMap type="com.bonus.canteen.core.cook.domain.CookRecipe" id="CookRecipeResult">
|
|
<result property="recipeId" column="recipe_id" />
|
|
<result property="recipeName" column="recipe_name" />
|
|
<result property="recipeType" column="recipe_type" />
|
|
<result property="stallId" column="stall_id" />
|
|
<result property="stallName" column="stall_name" />
|
|
<result property="canteenId" column="canteen_id" />
|
|
<result property="canteenName" column="canteen_name" />
|
|
<result property="areaName" column="area_name" />
|
|
<result property="planId" column="plan_id" />
|
|
<result property="effectDate" column="effect_date" />
|
|
<result property="expireDate" column="expire_date" />
|
|
<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="selectCookRecipeVo">
|
|
select cr.recipe_id, cr.recipe_name, cr.recipe_type, cr.stall_id, cr.canteen_id, cr.plan_id, cr.effect_date,
|
|
cr.expire_date, cr.create_by, cr.create_time, cr.update_by, cr.update_time,
|
|
bs.stall_name, bc.canteen_name, ba.area_name
|
|
from cook_recipe cr
|
|
left join basic_stall bs on bs.stall_id = cr.stall_id
|
|
left join basic_canteen bc on bc.canteen_id = bs.canteen_id
|
|
left join basic_area ba on ba.area_id = bc.area_id
|
|
</sql>
|
|
|
|
<select id="selectCookRecipeList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" resultMap="CookRecipeResult">
|
|
<include refid="selectCookRecipeVo"/>
|
|
<where>
|
|
<if test="recipeName != null and recipeName != ''"> and cr.recipe_name like concat('%', #{recipeName}, '%')</if>
|
|
<if test="recipeType != null "> and cr.recipe_type = #{recipeType}</if>
|
|
<if test="stallId != null "> and cr.stall_id = #{stallId}</if>
|
|
<if test="canteenId != null "> and cr.canteen_id = #{canteenId}</if>
|
|
<if test="planId != null and planId != ''"> and cr.plan_id = #{planId}</if>
|
|
<if test="effectDate != null "> and cr.effect_date = #{effectDate}</if>
|
|
<if test="expireDate != null "> and cr.expire_date = #{expireDate}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getDishesCount4PointDates" resultType="Integer">
|
|
select count(1)
|
|
from cook_recipe_dishes where recipe_detail_id in
|
|
(select recipe_detail_id from cook_recipe_detail where recipe_id = #{recipeId} and apply_date >= NOW()-1)
|
|
</select>
|
|
|
|
<select id="getDishesCount4Recycle" resultType="Integer">
|
|
select count(1) from cook_recipe_dishes where recipe_detail_id in
|
|
(select recipe_detail_id from cook_recipe_detail where recipe_id = #{recipeId} and detail_type = 1)
|
|
</select>
|
|
|
|
<select id="selectCookRecipeByRecipeId" parameterType="Long" resultMap="CookRecipeResult">
|
|
<include refid="selectCookRecipeVo"/>
|
|
where cr.recipe_id = #{recipeId}
|
|
</select>
|
|
|
|
<select id="selectCookRecipeByRecipeName" parameterType="String" resultMap="CookRecipeResult">
|
|
<include refid="selectCookRecipeVo"/>
|
|
where cr.recipe_name = #{recipeName}
|
|
</select>
|
|
|
|
<insert id="insertCookRecipe" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" useGeneratedKeys="true" keyProperty="recipeId">
|
|
insert into cook_recipe
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="recipeName != null and recipeName != ''">recipe_name,</if>
|
|
<if test="recipeType != null">recipe_type,</if>
|
|
<if test="stallId != null">stall_id,</if>
|
|
<if test="canteenId != null">canteen_id,</if>
|
|
<if test="planId != null">plan_id,</if>
|
|
<if test="effectDate != null">effect_date,</if>
|
|
<if test="expireDate != null">expire_date,</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="recipeName != null and recipeName != ''">#{recipeName},</if>
|
|
<if test="recipeType != null">#{recipeType},</if>
|
|
<if test="stallId != null">#{stallId},</if>
|
|
<if test="canteenId != null">#{canteenId},</if>
|
|
<if test="planId != null">#{planId},</if>
|
|
<if test="effectDate != null">#{effectDate},</if>
|
|
<if test="expireDate != null">#{expireDate},</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="updateCookRecipe" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe">
|
|
update cook_recipe
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="recipeName != null and recipeName != ''">recipe_name = #{recipeName},</if>
|
|
<if test="recipeType != null">recipe_type = #{recipeType},</if>
|
|
<if test="stallId != null">stall_id = #{stallId},</if>
|
|
<if test="canteenId != null">canteen_id = #{canteenId},</if>
|
|
<if test="planId != null">plan_id = #{planId},</if>
|
|
<if test="effectDate != null">effect_date = #{effectDate},</if>
|
|
<if test="expireDate != null">expire_date = #{expireDate},</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 recipe_id = #{recipeId}
|
|
</update>
|
|
|
|
<delete id="deleteCookRecipeByRecipeId" parameterType="Long">
|
|
delete from cook_recipe where recipe_id = #{recipeId}
|
|
</delete>
|
|
|
|
<delete id="deleteCookRecipeByRecipeIds" parameterType="String">
|
|
delete from cook_recipe where recipe_id in
|
|
<foreach item="recipeId" collection="array" open="(" separator="," close=")">
|
|
#{recipeId}
|
|
</foreach>
|
|
</delete>
|
|
</mapper> |