<?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.goods.mapper.TCanteenMenuMapper">
    
    <resultMap type="TCanteenMenu" id="TCanteenMenuResult">
        <result property="menuId"    column="menu_id"    />
        <result property="supplierId"    column="supplier_id"    />
        <result property="classifyId"    column="classify_id"    />
        <result property="goodsName"    column="goods_name"    />
        <result property="goodsNum"    column="goods_num"    />
        <result property="goodsPrice"    column="goods_price"    />
        <result property="goodsDes"    column="goods_des"    />
        <result property="discountStatus"    column="discount_status"    />
        <result property="discountPrice"    column="discount_price"    />
        <result property="discountIntensity"    column="discount_intensity"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTCanteenMenuVo">
        select menu_id, supplier_id, classify_id, goods_name, goods_num, goods_price, goods_des, discount_status, discount_price, discount_intensity, status, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, remarks from t_canteen_menu
    </sql>

    <select id="selectTCanteenMenuList" parameterType="TCanteenMenu" resultMap="TCanteenMenuResult">
        <include refid="selectTCanteenMenuVo"/>
        <where>  
            <if test="supplierId != null "> and supplier_id = #{supplierId}</if>
            <if test="classifyId != null "> and classify_id = #{classifyId}</if>
            <if test="goodsName != null  and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
            <if test="goodsNum != null "> and goods_num = #{goodsNum}</if>
            <if test="goodsPrice != null  and goodsPrice != ''"> and goods_price = #{goodsPrice}</if>
            <if test="goodsDes != null  and goodsDes != ''"> and goods_des = #{goodsDes}</if>
            <if test="discountStatus != null  and discountStatus != ''"> and discount_status = #{discountStatus}</if>
            <if test="discountPrice != null  and discountPrice != ''"> and discount_price = #{discountPrice}</if>
            <if test="discountIntensity != null  and discountIntensity != ''"> and discount_intensity = #{discountIntensity}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createrCode != null "> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null "> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTCanteenMenuByMenuId" parameterType="Long" resultMap="TCanteenMenuResult">
        <include refid="selectTCanteenMenuVo"/>
        where menu_id = #{menuId}
    </select>

    <insert id="insertTCanteenMenu" parameterType="TCanteenMenu" useGeneratedKeys="true" keyProperty="menuId">
        insert into t_canteen_menu
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="supplierId != null">supplier_id,</if>
            <if test="classifyId != null">classify_id,</if>
            <if test="goodsName != null">goods_name,</if>
            <if test="goodsNum != null">goods_num,</if>
            <if test="goodsPrice != null">goods_price,</if>
            <if test="goodsDes != null">goods_des,</if>
            <if test="discountStatus != null">discount_status,</if>
            <if test="discountPrice != null">discount_price,</if>
            <if test="discountIntensity != null">discount_intensity,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="supplierId != null">#{supplierId},</if>
            <if test="classifyId != null">#{classifyId},</if>
            <if test="goodsName != null">#{goodsName},</if>
            <if test="goodsNum != null">#{goodsNum},</if>
            <if test="goodsPrice != null">#{goodsPrice},</if>
            <if test="goodsDes != null">#{goodsDes},</if>
            <if test="discountStatus != null">#{discountStatus},</if>
            <if test="discountPrice != null">#{discountPrice},</if>
            <if test="discountIntensity != null">#{discountIntensity},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTCanteenMenu" parameterType="TCanteenMenu">
        update t_canteen_menu
        <trim prefix="SET" suffixOverrides=",">
            <if test="supplierId != null">supplier_id = #{supplierId},</if>
            <if test="classifyId != null">classify_id = #{classifyId},</if>
            <if test="goodsName != null">goods_name = #{goodsName},</if>
            <if test="goodsNum != null">goods_num = #{goodsNum},</if>
            <if test="goodsPrice != null">goods_price = #{goodsPrice},</if>
            <if test="goodsDes != null">goods_des = #{goodsDes},</if>
            <if test="discountStatus != null">discount_status = #{discountStatus},</if>
            <if test="discountPrice != null">discount_price = #{discountPrice},</if>
            <if test="discountIntensity != null">discount_intensity = #{discountIntensity},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where menu_id = #{menuId}
    </update>

    <delete id="deleteTCanteenMenuByMenuId" parameterType="Long">
        delete from t_canteen_menu where menu_id = #{menuId}
    </delete>

    <delete id="deleteTCanteenMenuByMenuIds" parameterType="String">
        delete from t_canteen_menu where menu_id in 
        <foreach item="menuId" collection="array" open="(" separator="," close=")">
            #{menuId}
        </foreach>
    </delete>
</mapper>