2025-04-03 15:06:05 +08:00
|
|
|
<?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">
|
2025-04-05 19:12:26 +08:00
|
|
|
<mapper namespace="com.bonus.canteen.core.menu.mapper.MenuRecipeMapper">
|
|
|
|
|
<resultMap type="com.bonus.canteen.core.menu.domain.MenuRecipe" id="MenuRecipeResult">
|
2025-04-03 15:06:05 +08:00
|
|
|
<result property="id" column="id" />
|
|
|
|
|
<result property="recipeId" column="recipe_id" />
|
|
|
|
|
<result property="planId" column="plan_id" />
|
|
|
|
|
<result property="recipeName" column="recipe_name" />
|
|
|
|
|
<result property="isDefault" column="is_default" />
|
|
|
|
|
<result property="recipeType" column="recipe_type" />
|
|
|
|
|
<result property="effectDate" column="effect_date" />
|
|
|
|
|
<result property="expireDate" column="expire_date" />
|
|
|
|
|
<result property="canteenId" column="canteen_id" />
|
|
|
|
|
<result property="stallId" column="stall_id" />
|
|
|
|
|
<result property="enableFlag" column="enable_flag" />
|
|
|
|
|
<result property="revision" column="revision" />
|
|
|
|
|
<result property="createBy" column="create_by" />
|
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
|
<result property="updateBy" column="update_by" />
|
|
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectMenuRecipeVo">
|
|
|
|
|
select id, recipe_id, plan_id, recipe_name, is_default, recipe_type, effect_date, expire_date, canteen_id, stall_id, enable_flag, revision, create_by, create_time, update_by, update_time, remark from menu_recipe
|
|
|
|
|
</sql>
|
|
|
|
|
|
2025-04-05 19:12:26 +08:00
|
|
|
<select id="selectMenuRecipeList" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe" resultMap="MenuRecipeResult">
|
2025-04-03 15:06:05 +08:00
|
|
|
<include refid="selectMenuRecipeVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="recipeId != null "> and recipe_id = #{recipeId}</if>
|
|
|
|
|
<if test="planId != null and planId != ''"> and plan_id = #{planId}</if>
|
|
|
|
|
<if test="recipeName != null and recipeName != ''"> and recipe_name like concat('%', #{recipeName}, '%')</if>
|
|
|
|
|
<if test="isDefault != null "> and is_default = #{isDefault}</if>
|
|
|
|
|
<if test="recipeType != null "> and recipe_type = #{recipeType}</if>
|
|
|
|
|
<if test="effectDate != null "> and effect_date = #{effectDate}</if>
|
|
|
|
|
<if test="expireDate != null "> and expire_date = #{expireDate}</if>
|
|
|
|
|
<if test="canteenId != null "> and canteen_id = #{canteenId}</if>
|
|
|
|
|
<if test="stallId != null "> and stall_id = #{stallId}</if>
|
|
|
|
|
<if test="enableFlag != null "> and enable_flag = #{enableFlag}</if>
|
|
|
|
|
<if test="revision != null "> and revision = #{revision}</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectMenuRecipeById" parameterType="Long" resultMap="MenuRecipeResult">
|
|
|
|
|
<include refid="selectMenuRecipeVo"/>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</select>
|
2025-04-14 13:14:16 +08:00
|
|
|
<select id="getDishesList" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeV2VO">
|
|
|
|
|
select
|
|
|
|
|
mr.recipe_id,
|
|
|
|
|
mr.recipe_name,
|
|
|
|
|
mr.recipe_type,
|
|
|
|
|
ac.canteen_id,
|
|
|
|
|
ac.canteen_name,
|
|
|
|
|
aa.area_id,
|
|
|
|
|
aa.area_name,
|
|
|
|
|
a.stall_id,
|
|
|
|
|
a.stall_name,
|
|
|
|
|
mr.create_time,
|
|
|
|
|
mr.create_by
|
|
|
|
|
from
|
|
|
|
|
menu_recipe mr
|
|
|
|
|
left join alloc_canteen ac on mr.canteen_id = ac.canteen_id
|
|
|
|
|
left join alloc_stall a on mr.stall_id = a.stall_id
|
|
|
|
|
left join alloc_area aa on ac.area_id = aa.area_id
|
|
|
|
|
where 1 = 1
|
|
|
|
|
<if test="recipeId != null ">
|
|
|
|
|
and mr.recipe_id = #{recipeId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="areaIds != null and areaIds.size >0">
|
|
|
|
|
and aa.area_id in
|
|
|
|
|
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
|
|
|
|
|
#{areaId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">
|
|
|
|
|
and mr.recipe_name like concat('%', #{recipeName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="canteenId != null and canteenId !=-1">
|
|
|
|
|
and mr.canteen_id = #{canteenId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="canteenIds != null and canteenIds.size >0">
|
|
|
|
|
and ac.canteen_id in
|
|
|
|
|
<foreach collection="canteenIds" item="canteenId" open="(" separator="," close=")">
|
|
|
|
|
#{canteenId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="stallId != null and stallId !=-1">
|
|
|
|
|
and mr.stall_id = #{stallId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="stallIds != null and stallIds.size >0">
|
|
|
|
|
and a.stall_id in
|
|
|
|
|
<foreach collection="stallIds" item="stallId" open="(" separator="," close=")">
|
|
|
|
|
#{stallId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="areaId != null and areaId !=-1">
|
|
|
|
|
and ac.area_id = #{areaId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="areaIds != null and areaIds.size >0">
|
|
|
|
|
and ac.area_id in
|
|
|
|
|
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
|
|
|
|
|
#{areaId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="recipeType != null">
|
|
|
|
|
and mr.recipe_type = #{recipeType}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getDishesCountByRecipeIds" resultType="com.bonus.canteen.core.menu.dto.RecipeDishesCountDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
mrd.recipe_id,count(DISTINCT(md.base_dishes_id)) as num
|
|
|
|
|
FROM
|
|
|
|
|
menu_recipe_detail mrd
|
|
|
|
|
LEFT JOIN menu_recipe_dishes mrdd ON mrd.detail_id = mrdd.detail_id
|
|
|
|
|
LEFT JOIN menu_dishes md ON md.dishes_id = mrdd.dishes_id
|
|
|
|
|
where
|
|
|
|
|
mrd.apply_date >= curdate()
|
|
|
|
|
<if test="recipeIds !=null and recipeIds.size()>0">
|
|
|
|
|
AND mrd.recipe_id in
|
|
|
|
|
<foreach collection="recipeIds" separator="," open="(" close=")" item="item">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY mrd.recipe_id
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectApplyDateListByRecipeId" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeDataVO">
|
|
|
|
|
SELECT recipe_id as recipeId, apply_date as applyData
|
|
|
|
|
FROM menu_recipe_detail
|
|
|
|
|
WHERE apply_date >= #{applyDate}
|
|
|
|
|
<if test="recipeIds !=null and recipeIds.size()>0">
|
|
|
|
|
AND recipe_id IN
|
|
|
|
|
<foreach collection="recipeIds" open="(" close=")" item="item" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
</select>
|
2025-04-14 13:41:13 +08:00
|
|
|
<select id="selectBaseSizeDishesId" resultType="com.bonus.canteen.core.menu.model.MenuBaseModel">
|
|
|
|
|
select
|
|
|
|
|
base_dishes_id,
|
|
|
|
|
dishes_id,
|
|
|
|
|
size_json
|
|
|
|
|
from
|
|
|
|
|
menu_dishes
|
|
|
|
|
where
|
|
|
|
|
base_dishes_id in
|
|
|
|
|
<foreach collection="baseDishesIdList" item="baseDishesId" separator="," open="(" close=")">
|
|
|
|
|
#{baseDishesId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
2025-04-14 13:14:16 +08:00
|
|
|
|
2025-04-05 19:12:26 +08:00
|
|
|
<insert id="insertMenuRecipe" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe" useGeneratedKeys="true" keyProperty="id">
|
2025-04-03 15:06:05 +08:00
|
|
|
insert into menu_recipe
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="recipeId != null">recipe_id,</if>
|
|
|
|
|
<if test="planId != null">plan_id,</if>
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">recipe_name,</if>
|
|
|
|
|
<if test="isDefault != null">is_default,</if>
|
|
|
|
|
<if test="recipeType != null">recipe_type,</if>
|
|
|
|
|
<if test="effectDate != null">effect_date,</if>
|
|
|
|
|
<if test="expireDate != null">expire_date,</if>
|
|
|
|
|
<if test="canteenId != null">canteen_id,</if>
|
|
|
|
|
<if test="stallId != null">stall_id,</if>
|
|
|
|
|
<if test="enableFlag != null">enable_flag,</if>
|
|
|
|
|
<if test="revision != null">revision,</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>
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="recipeId != null">#{recipeId},</if>
|
|
|
|
|
<if test="planId != null">#{planId},</if>
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">#{recipeName},</if>
|
|
|
|
|
<if test="isDefault != null">#{isDefault},</if>
|
|
|
|
|
<if test="recipeType != null">#{recipeType},</if>
|
|
|
|
|
<if test="effectDate != null">#{effectDate},</if>
|
|
|
|
|
<if test="expireDate != null">#{expireDate},</if>
|
|
|
|
|
<if test="canteenId != null">#{canteenId},</if>
|
|
|
|
|
<if test="stallId != null">#{stallId},</if>
|
|
|
|
|
<if test="enableFlag != null">#{enableFlag},</if>
|
|
|
|
|
<if test="revision != null">#{revision},</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>
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2025-04-05 19:12:26 +08:00
|
|
|
<update id="updateMenuRecipe" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe">
|
2025-04-03 15:06:05 +08:00
|
|
|
update menu_recipe
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="recipeId != null">recipe_id = #{recipeId},</if>
|
|
|
|
|
<if test="planId != null">plan_id = #{planId},</if>
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">recipe_name = #{recipeName},</if>
|
|
|
|
|
<if test="isDefault != null">is_default = #{isDefault},</if>
|
|
|
|
|
<if test="recipeType != null">recipe_type = #{recipeType},</if>
|
|
|
|
|
<if test="effectDate != null">effect_date = #{effectDate},</if>
|
|
|
|
|
<if test="expireDate != null">expire_date = #{expireDate},</if>
|
|
|
|
|
<if test="canteenId != null">canteen_id = #{canteenId},</if>
|
|
|
|
|
<if test="stallId != null">stall_id = #{stallId},</if>
|
|
|
|
|
<if test="enableFlag != null">enable_flag = #{enableFlag},</if>
|
|
|
|
|
<if test="revision != null">revision = #{revision},</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>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteMenuRecipeById" parameterType="Long">
|
|
|
|
|
delete from menu_recipe where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteMenuRecipeByIds" parameterType="String">
|
|
|
|
|
delete from menu_recipe where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
</mapper>
|