<?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.TCanteenQualificationMapper">
    
    <resultMap type="TCanteenQualification" id="TCanteenQualificationResult">
        <result property="qualificationId"    column="qualification_id"    />
        <result property="supplierId"    column="supplier_id"    />
        <result property="qualificationUrl"    column="qualification_url"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="documentType"    column="document_type"    />
        <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="selectTCanteenQualificationVo">
        select qualification_id, supplier_id, qualification_url, start_date, end_date, document_type, status, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, remarks from t_canteen_qualification
    </sql>

    <select id="selectTCanteenQualificationList" parameterType="TCanteenQualification" resultMap="TCanteenQualificationResult">
        <include refid="selectTCanteenQualificationVo"/>
        <where>  
            <if test="supplierId != null "> and supplier_id = #{supplierId}</if>
            <if test="qualificationUrl != null  and qualificationUrl != ''"> and qualification_url = #{qualificationUrl}</if>
            <if test="startDate != null "> and start_date = #{startDate}</if>
            <if test="endDate != null "> and end_date = #{endDate}</if>
            <if test="documentType != null  and documentType != ''"> and document_type = #{documentType}</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="selectTCanteenQualificationByQualificationId" parameterType="Long" resultMap="TCanteenQualificationResult">
        <include refid="selectTCanteenQualificationVo"/>
        where qualification_id = #{qualificationId}
    </select>

    <insert id="insertTCanteenQualification" parameterType="TCanteenQualification" useGeneratedKeys="true" keyProperty="qualificationId">
        insert into t_canteen_qualification
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="supplierId != null">supplier_id,</if>
            <if test="qualificationUrl != null">qualification_url,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="documentType != null">document_type,</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="qualificationUrl != null">#{qualificationUrl},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="documentType != null">#{documentType},</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="updateTCanteenQualification" parameterType="TCanteenQualification">
        update t_canteen_qualification
        <trim prefix="SET" suffixOverrides=",">
            <if test="supplierId != null">supplier_id = #{supplierId},</if>
            <if test="qualificationUrl != null">qualification_url = #{qualificationUrl},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="documentType != null">document_type = #{documentType},</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 qualification_id = #{qualificationId}
    </update>

    <delete id="deleteTCanteenQualificationByQualificationId" parameterType="Long">
        delete from t_canteen_qualification where qualification_id = #{qualificationId}
    </delete>

    <delete id="deleteTCanteenQualificationByQualificationIds" parameterType="String">
        delete from t_canteen_qualification where qualification_id in 
        <foreach item="qualificationId" collection="array" open="(" separator="," close=")">
            #{qualificationId}
        </foreach>
    </delete>
</mapper>