<?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.project.sems.mapper.TApproverFileMapper">
    
    <resultMap type="TApproverFile" id="TApproverFileResult">
        <result property="id"    column="id"    />
        <result property="approveId"    column="approve_id"    />
        <result property="fileName"    column="file_name"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="createTime"    column="create_time"    />
        <result property="fileType"    column="file_type"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTApproverFileVo">
        select d.id, d.approve_id, d.file_name, d.file_url, d.create_time, d.file_type from t_approver_file d
    </sql>

    <select id="selectTApproverFileList" parameterType="TApproverFile" resultMap="TApproverFileResult">
        <include refid="selectTApproverFileVo"/>
        <where>  
            <if test="approveId != null "> and approve_id = #{approveId}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat(concat('%', #{fileName}), '%')</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
            <if test="fileType != null "> and file_type = #{fileType}</if>
        </where>
    </select>
    
    <select id="selectTApproverFileById" parameterType="Long" resultMap="TApproverFileResult">
        <include refid="selectTApproverFileVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTApproverFile" parameterType="TApproverFile">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_approver_file.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_approver_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="approveId != null">approve_id,</if>
            <if test="fileName != null">file_name,</if>
            <if test="fileUrl != null">file_url,</if>
            <if test="createTime != null">create_time,</if>
            <if test="fileType != null">file_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="approveId != null">#{approveId},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="fileType != null">#{fileType},</if>
         </trim>
    </insert>

    <update id="updateTApproverFile" parameterType="TApproverFile">
        update t_approver_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="approveId != null">approve_id = #{approveId},</if>
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="fileType != null">file_type = #{fileType},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTApproverFileById" parameterType="Long">
        update t_approver_file set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTApproverFileByIds" parameterType="String">
        update t_approver_file set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    
</mapper>