<?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.mapper.TrsAttachmentMapper">
    
    <resultMap type="TrsAttachment" id="TrsAttachmentResult">
        <result property="id"    column="id"    />
        <result property="fileName"    column="file_name"    />
        <result property="description"    column="description"    />
        <result property="filePath"    column="file_path"    />
        <result property="fileSize"    column="file_size"    />
        <result property="fileType"    column="file_type"    />
        <result property="record"    column="record"    />
        <result property="msg"    column="msg"    />
        <result property="time"    column="time"    />
    </resultMap>

    <sql id="selectTrsAttachmentVo">
        select id, file_name,description, file_path, file_size, file_type, record, msg, time from trs_attachment
    </sql>

    <select id="selectTrsAttachmentList" parameterType="TrsAttachment" resultMap="TrsAttachmentResult">
        <include refid="selectTrsAttachmentVo"/>
        <where>  
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="fileType != null  and fileType != ''"> and file_type = #{fileType}</if>
        </where>
    </select>
    
    <select id="selectTrsAttachmentById" parameterType="Long" resultMap="TrsAttachmentResult">
        <include refid="selectTrsAttachmentVo"/>
        where id = #{id}
    </select>

    <insert id="insertTrsAttachment" parameterType="TrsAttachment">
        insert into trs_attachment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="fileName != null">file_name,</if>
            <if test="description != null">description,</if>
            <if test="filePath != null">file_path,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="fileType != null">file_type,</if>
            <if test="record != null">record,</if>
            <if test="msg != null">msg,</if>
            <if test="time != null">time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="description != null">#{description},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="fileType != null">#{fileType},</if>
            <if test="record != null">#{record},</if>
            <if test="msg != null">#{msg},</if>
            <if test="time != null">#{time},</if>
         </trim>
    </insert>

    <update id="updateTrsAttachment" parameterType="TrsAttachment">
        update trs_attachment
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="description != null">description = #{description},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="fileSize != null">file_size = #{fileSize},</if>
            <if test="fileType != null">file_type = #{fileType},</if>
            <if test="record != null">record = #{record},</if>
            <if test="msg != null">msg = #{msg},</if>
            <if test="time != null">time = #{time},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTrsAttachmentById" parameterType="Long">
        delete from trs_attachment where id = #{id}
    </delete>

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

</mapper>