<?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.FeedbackFileMapper">
    
    <resultMap type="FeedbackFile" id="FeedbackFileResult">
        <result property="fileId"    column="file_id"    />
        <result property="fileName"    column="file_name"    />
        <result property="filePath"    column="file_path"    />
        <result property="feedbackId"    column="feedback_id"    />
    </resultMap>

    <sql id="selectFeedbackFileVo">
        select file_id, file_name, file_path, feedback_id from sys_feedback_file
    </sql>

    <select id="selectFeedbackFileList" parameterType="FeedbackFile" resultMap="FeedbackFileResult">
        <include refid="selectFeedbackFileVo"/>
        <where>  
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
            <if test="feedbackId != null "> and feedback_id = #{feedbackId}</if>
        </where>
    </select>
    
    <select id="selectFeedbackFileById" parameterType="Long" resultMap="FeedbackFileResult">
        <include refid="selectFeedbackFileVo"/>
        where file_id = #{fileId}
    </select>
        
    <insert id="insertFeedbackFile" parameterType="FeedbackFile" useGeneratedKeys="true" keyProperty="fileId">
        insert into sys_feedback_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileName != null">file_name,</if>
            <if test="filePath != null">file_path,</if>
            <if test="feedbackId != null">feedback_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileName != null">#{fileName},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="feedbackId != null">#{feedbackId},</if>
         </trim>
    </insert>

    <update id="updateFeedbackFile" parameterType="FeedbackFile">
        update sys_feedback_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="feedbackId != null">feedback_id = #{feedbackId},</if>
        </trim>
        where file_id = #{fileId}
    </update>

    <delete id="deleteFeedbackFileById" parameterType="Long">
        delete from sys_feedback_file where file_id = #{fileId}
    </delete>

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

        <insert id="batchFileInfo">
        insert into sys_feedback_file (file_name, file_path,feedback_id) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.fileName},#{item.filePath},#{item.feedbackId})
        </foreach>
    </insert>
</mapper>