<?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.TdFileReceiveMapper">
    
    <resultMap type="TdFileReceive" id="TdFileReceiveResult">
        <result property="receiveId"    column="receive_id"    />
        <result property="fileId"    column="file_id"    />
        <result property="fileName"    column="file_name"    />
        <result property="provideDepart"    column="provide_depart"    />
        <result property="provideDate"    column="provide_date"    />
        <result property="receiveDepartid"    column="receive_departid"    />
        <result property="receiveState"    column="receive_state"    />
        <result property="receiveUserid"    column="receive_userid"    />
        <result property="receiveDate"    column="receive_date"    />
        <result property="extractState"    column="extract_state"    />
        <result property="extractDepartid"    column="extract_departid"    />
        <result property="extractUserid"    column="extract_userid"    />
        <result property="extractDate"    column="extract_date"    />
        <result property="destoryState"    column="destory_state"    />
        <result property="destoryAddress"    column="destory_address"    />
        <result property="destoryDepart"    column="destory_depart"    />
        <result property="destoryUsername"    column="destory_username"    />
        <result property="destoryStyle"    column="destory_style"    />
        <result property="destoryCount"    column="destory_count"    />
        <result property="destoryDate"    column="destory_date"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTdFileReceiveVo">
        select receive_id, file_id, file_name, provide_depart, provide_date, receive_departid, receive_state, receive_userid, receive_date, extract_state, extract_departid, extract_userid, extract_date, destory_state,destory_address, destory_depart, destory_username, destory_style, destory_count, destory_date, remark from td_file_receive
    </sql>

    <select id="selectTdFileReceiveList" parameterType="TdFileReceive" resultMap="TdFileReceiveResult">
        <include refid="selectTdFileReceiveVo"/>
        <where>  
            <if test="fileId != null  and fileId != ''"> and file_id = #{fileId}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="provideDepart != null  and provideDepart != ''"> and provide_depart = #{provideDepart}</if>
            <if test="provideDate != null "> and provide_date = #{provideDate}</if>
            <if test="receiveDepartid != null  and receiveDepartid != ''"> and receive_departid = #{receiveDepartid}</if>
            <if test="receiveState != null  and receiveState != ''"> and receive_state = #{receiveState}</if>
            <if test="receiveUserid != null  and receiveUserid != ''"> and receive_userid = #{receiveUserid}</if>
            <if test="receiveDate != null "> and receive_date = #{receiveDate}</if>
            <if test="extractState != null  and extractState != ''"> and extract_state = #{extractState}</if>
            <if test="extractDepartid != null  and extractDepartid != ''"> and extract_departid = #{extractDepartid}</if>
            <if test="extractUserid != null  and extractUserid != ''"> and extract_userid = #{extractUserid}</if>
            <if test="extractDate != null "> and extract_date = #{extractDate}</if>
            <if test="destoryState != null  and destoryState != ''"> and destory_state = #{destoryState}</if>
            <if test="destoryAddress != null  and destoryAddress != ''"> and destory_address = #{destoryAddress}</if>
            <if test="destoryDepart != null  and destoryDepart != ''"> and destory_depart = #{destoryDepart}</if>
            <if test="destoryUsername != null  and destoryUsername != ''"> and destory_username like concat('%', #{destoryUsername}, '%')</if>
            <if test="destoryStyle != null  and destoryStyle != ''"> and destory_style = #{destoryStyle}</if>
            <if test="destoryCount != null "> and destory_count = #{destoryCount}</if>
            <if test="destoryDate != null "> and destory_date = #{destoryDate}</if>
            <if test="remark != null "> and remark = #{remark}</if>

        </where>
    </select>
    
    <select id="selectTdFileReceiveByReceiveId" parameterType="Long" resultMap="TdFileReceiveResult">
        <include refid="selectTdFileReceiveVo"/>
        where receive_id = #{receiveId}
    </select>

    <select id="selectTdFileReceiveByFileId" parameterType="String" resultMap="TdFileReceiveResult">
        <include refid="selectTdFileReceiveVo"/>
        where file_id = #{fileId}
    </select>

    <select id="selectTdFileReceiveByReceiveDepart" parameterType="String" resultMap="TdFileReceiveResult">
        <include refid="selectTdFileReceiveVo"/>
        where receive_departid = #{receiveDepartid}
    </select>
        
    <insert id="insertTdFileReceive" parameterType="TdFileReceive" useGeneratedKeys="true" keyProperty="receiveId">
        insert into td_file_receive
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileId != null">file_id,</if>
            <if test="fileName != null">file_name,</if>
            <if test="provideDepart != null">provide_depart,</if>
            <if test="provideDate != null">provide_date,</if>
            <if test="receiveDepartid != null">receive_departid,</if>
            <if test="receiveState != null">receive_state,</if>
            <if test="receiveUserid != null">receive_userid,</if>
            <if test="receiveDate != null">receive_date,</if>
            <if test="extractState != null">extract_state,</if>
            <if test="extractDepartid != null">extract_departid,</if>
            <if test="extractUserid != null">extract_userid,</if>
            <if test="extractDate != null">extract_date,</if>
            <if test="destoryState != null">destory_state,</if>
            <if test="destoryAddress != null">destory_address,</if>
            <if test="destoryDepart != null">destory_depart,</if>
            <if test="destoryUsername != null">destory_username,</if>
            <if test="destoryStyle != null">destory_style,</if>
            <if test="destoryCount != null">destory_count,</if>
            <if test="destoryDate != null">destory_date,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileId != null">#{fileId},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="provideDepart != null">#{provideDepart},</if>
            <if test="provideDate != null">#{provideDate},</if>
            <if test="receiveDepartid != null">#{receiveDepartid},</if>
            <if test="receiveState != null">#{receiveState},</if>
            <if test="receiveUserid != null">#{receiveUserid},</if>
            <if test="receiveDate != null">#{receiveDate},</if>
            <if test="extractState != null">#{extractState},</if>
            <if test="extractDepartid != null">#{extractDepartid},</if>
            <if test="extractUserid != null">#{extractUserid},</if>
            <if test="extractDate != null">#{extractDate},</if>
            <if test="destoryState != null">#{destoryState},</if>
            <if test="destoryAddress != null">#{destoryAddress},</if>
            <if test="destoryDepart != null">#{destoryDepart},</if>
            <if test="destoryUsername != null">#{destoryUsername},</if>
            <if test="destoryStyle != null">#{destoryStyle},</if>
            <if test="destoryCount != null">#{destoryCount},</if>
            <if test="destoryDate != null">#{destoryDate},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTdFileReceive" parameterType="TdFileReceive">
        update td_file_receive
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileId != null">file_id = #{fileId},</if>
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="provideDepart != null">provide_depart = #{provideDepart},</if>
            <if test="provideDate != null">provide_date = #{provideDate},</if>
            <if test="receiveDepartid != null">receive_departid = #{receiveDepartid},</if>
            <if test="receiveState != null">receive_state = #{receiveState},</if>
            <if test="receiveUserid != null">receive_userid = #{receiveUserid},</if>
            <if test="receiveDate != null">receive_date = #{receiveDate},</if>
            <if test="extractState != null">extract_state = #{extractState},</if>
            <if test="extractDepartid != null">extract_departid = #{extractDepartid},</if>
            <if test="extractUserid != null">extract_userid = #{extractUserid},</if>
            <if test="extractDate != null">extract_date = #{extractDate},</if>
            <if test="destoryState != null">destory_state = #{destoryState},</if>
            <if test="destoryAddress != null">destory_address = #{destoryAddress},</if>
            <if test="destoryDepart != null">destory_depart = #{destoryDepart},</if>
            <if test="destoryUsername != null">destory_username = #{destoryUsername},</if>
            <if test="destoryStyle != null">destory_style = #{destoryStyle},</if>
            <if test="destoryCount != null">destory_count = #{destoryCount},</if>
            <if test="destoryDate != null">destory_date = #{destoryDate},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where receive_id = #{receiveId}
    </update>

    <delete id="deleteTdFileReceiveByReceiveId" parameterType="Long">
        delete from td_file_receive where receive_id = #{receiveId}
    </delete>

    <delete id="deleteTdFileReceiveByReceiveIds" parameterType="String">
        delete from td_file_receive where receive_id in 
        <foreach item="receiveId" collection="array" open="(" separator="," close=")">
            #{receiveId}
        </foreach>
    </delete>

</mapper>