|
@@ -0,0 +1,128 @@
|
|
|
+<?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.ruoyi.system.mapper.MenuBoxMapper">
|
|
|
+
|
|
|
+ <resultMap type="MenuBox" id="MenuBoxResult">
|
|
|
+ <result property="menuBoxId" column="menu_box_id" />
|
|
|
+ <result property="parentId" column="parent_id" />
|
|
|
+ <result property="ancestors" column="ancestors" />
|
|
|
+ <result property="foodName" column="food_name" />
|
|
|
+ <result property="foodPhoto" column="food_photo" />
|
|
|
+ <result property="suggest" column="suggest" />
|
|
|
+ <result property="suggestLv" column="suggest_lv" />
|
|
|
+ <result property="parentName" column="parent_name" />
|
|
|
+ <result property="isDel" column="is_del" />
|
|
|
+ <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="selectMenuBoxVo">
|
|
|
+ select menu_box_id, parent_id, ancestors, food_name, food_photo, suggest, suggest_lv, is_del, create_by, create_time, update_by, update_time from menu_box
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectMenuBoxList" parameterType="MenuBox" resultMap="MenuBoxResult">
|
|
|
+ <include refid="selectMenuBoxVo"/>
|
|
|
+ <where>
|
|
|
+ <if test="parentId != null "> and parent_id = #{parentId}</if>
|
|
|
+ <if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
|
|
|
+ <if test="foodName != null and foodName != ''"> and food_name like concat('%', #{foodName}, '%')</if>
|
|
|
+ <if test="foodPhoto != null and foodPhoto != ''"> and food_photo = #{foodPhoto}</if>
|
|
|
+ <if test="suggest != null and suggest != ''"> and suggest = #{suggest}</if>
|
|
|
+ <if test="suggestLv != null and suggestLv != ''"> and suggest_lv = #{suggestLv}</if>
|
|
|
+ <if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectMenuBoxByMenuBoxId" parameterType="Long" resultMap="MenuBoxResult">
|
|
|
+ <include refid="selectMenuBoxVo"/>
|
|
|
+ where menu_box_id = #{menuBoxId}
|
|
|
+ </select>
|
|
|
+ <select id="checkMenuBoxNameUnique" resultMap="MenuBoxResult">
|
|
|
+ <include refid="selectMenuBoxVo"/>
|
|
|
+ where food_name=#{foodName} and parent_id = #{parentId} and is_del = 'N' limit 1
|
|
|
+ </select>
|
|
|
+ <select id="selectMenuBoxById" parameterType="Long" resultMap="MenuBoxResult">
|
|
|
+ select b.menu_box_id, b.parent_id, b.ancestors, b.food_name, b.food_photo, b.suggest, b.suggest_lv, b.is_del,
|
|
|
+ (select food_name from menu_box where menu_box_id = b.parent_id) parent_name
|
|
|
+ from menu_box b
|
|
|
+ where b.menu_box_id = #{menuBoxId}
|
|
|
+ </select>
|
|
|
+ <select id="selectChildrenMenuBoxById" parameterType="Long" resultMap="MenuBoxResult">
|
|
|
+ select * from menu_box where find_in_set(#{menuBoxId}, ancestors)
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertMenuBox" parameterType="MenuBox" useGeneratedKeys="true" keyProperty="menuBoxId">
|
|
|
+ insert into menu_box
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="parentId != null">parent_id,</if>
|
|
|
+ <if test="ancestors != null">ancestors,</if>
|
|
|
+ <if test="foodName != null">food_name,</if>
|
|
|
+ <if test="foodPhoto != null">food_photo,</if>
|
|
|
+ <if test="suggest != null">suggest,</if>
|
|
|
+ <if test="suggestLv != null">suggest_lv,</if>
|
|
|
+ <if test="isDel != null">is_del,</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="parentId != null">#{parentId},</if>
|
|
|
+ <if test="ancestors != null">#{ancestors},</if>
|
|
|
+ <if test="foodName != null">#{foodName},</if>
|
|
|
+ <if test="foodPhoto != null">#{foodPhoto},</if>
|
|
|
+ <if test="suggest != null">#{suggest},</if>
|
|
|
+ <if test="suggestLv != null">#{suggestLv},</if>
|
|
|
+ <if test="isDel != null">#{isDel},</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="updateMenuBox" parameterType="MenuBox">
|
|
|
+ update menu_box
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="parentId != null">parent_id = #{parentId},</if>
|
|
|
+ <if test="ancestors != null">ancestors = #{ancestors},</if>
|
|
|
+ <if test="foodName != null">food_name = #{foodName},</if>
|
|
|
+ <if test="foodPhoto != null">food_photo = #{foodPhoto},</if>
|
|
|
+ <if test="suggest != null">suggest = #{suggest},</if>
|
|
|
+ <if test="suggestLv != null">suggest_lv = #{suggestLv},</if>
|
|
|
+ <if test="isDel != null">is_del = #{isDel},</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 menu_box_id = #{menuBoxId}
|
|
|
+ </update>
|
|
|
+ <update id="updateMenuBoxChildren" parameterType="java.util.List">
|
|
|
+ update menu_box set ancestors =
|
|
|
+ <foreach collection="menuBoxs" item="item" index="index"
|
|
|
+ separator=" " open="case menu_box_id" close="end">
|
|
|
+ when #{item.menuBoxId} then #{item.ancestors}
|
|
|
+ </foreach>
|
|
|
+ where menu_box_id in
|
|
|
+ <foreach collection="menuBoxs" item="item" index="index"
|
|
|
+ separator="," open="(" close=")">
|
|
|
+ #{item.menuBoxId}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteMenuBoxByMenuBoxId" parameterType="Long">
|
|
|
+ delete from menu_box where menu_box_id = #{menuBoxId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteMenuBoxByMenuBoxIds" parameterType="String">
|
|
|
+ delete from menu_box where menu_box_id in
|
|
|
+ <foreach item="menuBoxId" collection="array" open="(" separator="," close=")">
|
|
|
+ #{menuBoxId}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+</mapper>
|