<?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.supplier.mapper.TCanteenDailyMapper">
    
    <resultMap type="TCanteenDaily" id="TCanteenDailyResult">
        <result property="dailyId"    column="daily_id"    />
        <result property="supplierId"    column="supplier_id"    />
        <result property="uploadDate"    column="upload_date"    />
        <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="selectTCanteenDailyVo">
        select daily_id, supplier_id, upload_date, status, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, remarks from t_canteen_daily
    </sql>

    <select id="selectTCanteenDailyList" parameterType="TCanteenDaily" resultMap="TCanteenDailyResult">
        <include refid="selectTCanteenDailyVo"/>
        <where>  
            <if test="supplierId != null "> and supplier_id = #{supplierId}</if>
            <if test="uploadDate != null "> and upload_date = #{uploadDate}</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="selectTCanteenDailyByDailyId" parameterType="Long" resultMap="TCanteenDailyResult">
        <include refid="selectTCanteenDailyVo"/>
        where daily_id = #{dailyId}
    </select>

    <insert id="insertTCanteenDaily" parameterType="TCanteenDaily" useGeneratedKeys="true" keyProperty="dailyId">
        insert into t_canteen_daily
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="supplierId != null">supplier_id,</if>
            <if test="uploadDate != null">upload_date,</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="uploadDate != null">#{uploadDate},</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="updateTCanteenDaily" parameterType="TCanteenDaily">
        update t_canteen_daily
        <trim prefix="SET" suffixOverrides=",">
            <if test="supplierId != null">supplier_id = #{supplierId},</if>
            <if test="uploadDate != null">upload_date = #{uploadDate},</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 daily_id = #{dailyId}
    </update>

    <delete id="deleteTCanteenDailyByDailyId" parameterType="Long">
        delete from t_canteen_daily where daily_id = #{dailyId}
    </delete>

    <delete id="deleteTCanteenDailyByDailyIds" parameterType="String">
        delete from t_canteen_daily where daily_id in 
        <foreach item="dailyId" collection="array" open="(" separator="," close=")">
            #{dailyId}
        </foreach>
    </delete>
</mapper>