<?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.OrderFoodMapper">
    
    <resultMap type="OrderFood" id="OrderFoodResult">
        <result property="orderFoodId"    column="order_food_id"    />
        <result property="orderFoodTime"    column="order_food_time"    />
        <result property="orderFoodType"    column="order_food_type"    />
        <result property="orderFoodUser"    column="order_food_user"    />
        <result property="orderFoodUserId"    column="order_food_user_id"    />
        <result property="orderFoodDept"    column="order_food_dept"    />
        <result property="orderFoodDeptId"    column="order_food_dept_id"    />
        <result property="createDept"    column="create_dept"    />
        <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="selectOrderFoodVo">
        select order_food_id, order_food_time, order_food_type, order_food_user, order_food_user_id, order_food_dept, order_food_dept_id, create_dept, create_by, create_time, update_by, update_time, remark from order_food
    </sql>

    <select id="selectOrderFoodList" parameterType="OrderFood" resultMap="OrderFoodResult">
        <include refid="selectOrderFoodVo"/>
        <where>  
            <if test="orderFoodTime != null "> and order_food_time = #{orderFoodTime}</if>
            <if test="orderFoodType != null  and orderFoodType != ''"> and order_food_type = #{orderFoodType}</if>
            <if test="orderFoodUser != null  and orderFoodUser != ''"> and order_food_user = #{orderFoodUser}</if>
            <if test="orderFoodUserId != null "> and order_food_user_id = #{orderFoodUserId}</if>
            <if test="orderFoodDept != null  and orderFoodDept != ''"> and order_food_dept = #{orderFoodDept}</if>
            <if test="orderFoodDeptId != null "> and order_food_dept_id = #{orderFoodDeptId}</if>
            <if test="createDept != null "> and create_dept = #{createDept}</if>
        </where>
    </select>
    
    <select id="selectOrderFoodByOrderFoodId" parameterType="Long" resultMap="OrderFoodResult">
        <include refid="selectOrderFoodVo"/>
        where order_food_id = #{orderFoodId}
    </select>
        
    <insert id="insertOrderFood" parameterType="OrderFood" useGeneratedKeys="true" keyProperty="orderFoodId">
        insert into order_food
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderFoodTime != null">order_food_time,</if>
            <if test="orderFoodType != null">order_food_type,</if>
            <if test="orderFoodUser != null">order_food_user,</if>
            <if test="orderFoodUserId != null">order_food_user_id,</if>
            <if test="orderFoodDept != null">order_food_dept,</if>
            <if test="orderFoodDeptId != null">order_food_dept_id,</if>
            <if test="createDept != null">create_dept,</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="orderFoodTime != null">#{orderFoodTime},</if>
            <if test="orderFoodType != null">#{orderFoodType},</if>
            <if test="orderFoodUser != null">#{orderFoodUser},</if>
            <if test="orderFoodUserId != null">#{orderFoodUserId},</if>
            <if test="orderFoodDept != null">#{orderFoodDept},</if>
            <if test="orderFoodDeptId != null">#{orderFoodDeptId},</if>
            <if test="createDept != null">#{createDept},</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>

    <update id="updateOrderFood" parameterType="OrderFood">
        update order_food
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderFoodTime != null">order_food_time = #{orderFoodTime},</if>
            <if test="orderFoodType != null">order_food_type = #{orderFoodType},</if>
            <if test="orderFoodUser != null">order_food_user = #{orderFoodUser},</if>
            <if test="orderFoodUserId != null">order_food_user_id = #{orderFoodUserId},</if>
            <if test="orderFoodDept != null">order_food_dept = #{orderFoodDept},</if>
            <if test="orderFoodDeptId != null">order_food_dept_id = #{orderFoodDeptId},</if>
            <if test="createDept != null">create_dept = #{createDept},</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 order_food_id = #{orderFoodId}
    </update>

    <delete id="deleteOrderFoodByOrderFoodId" parameterType="Long">
        delete from order_food where order_food_id = #{orderFoodId}
    </delete>

    <delete id="deleteOrderFoodByOrderFoodIds" parameterType="String">
        delete from order_food where order_food_id in 
        <foreach item="orderFoodId" collection="array" open="(" separator="," close=")">
            #{orderFoodId}
        </foreach>
    </delete>
</mapper>