<?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.quot.mapper.QuotFileMapper">

    <resultMap type="QuotFile" id="QuotFileResult">
        <result property="fileId"    column="file_id"    />
        <result property="fileName"    column="file_name"    />
        <result property="fileBucketName"    column="file_bucket_name"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="fileSize"    column="file_size"    />
        <result property="fileTime"    column="file_time"    />
        <result property="fileType"    column="file_type"    />
        <result property="relationId"    column="relation_id"    />
    </resultMap>

    <sql id="selectQuotFileVo">
        select file_id, file_name, file_bucket_name, file_url, file_size, file_time, file_type, relation_id from quot_file
    </sql>

    <select id="selectQuotFileList" parameterType="QuotFile" resultMap="QuotFileResult">
        <include refid="selectQuotFileVo"/>
        <where>
            and relation_id = #{relationId}
            and file_type = #{fileType}
        </where>
        order by file_time desc
    </select>

    <select id="selectQuotFileByFileId" parameterType="String" resultMap="QuotFileResult">
        <include refid="selectQuotFileVo"/>
        where file_id = #{fileId}
    </select>

    <insert id="insertQuotFile" parameterType="QuotFile">
        insert into quot_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileId != null">file_id,</if>
            <if test="fileName != null">file_name,</if>
            <if test="fileBucketName != null">file_bucket_name,</if>
            <if test="fileUrl != null">file_url,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="fileTime != null">file_time,</if>
            <if test="fileType != null">file_type,</if>
            <if test="relationId != null">relation_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileId != null">#{fileId},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="fileBucketName != null">#{fileBucketName},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="fileTime != null">#{fileTime},</if>
            <if test="fileType != null">#{fileType},</if>
            <if test="relationId != null">#{relationId},</if>
         </trim>
    </insert>

    <delete id="deleteQuotFileByFileId" parameterType="String">
        delete from quot_file where file_id = #{fileId}
    </delete>
</mapper>