<!--<?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.backendsys.mapper.System.SysFileMapper">-->

<!--    <sql id="includeFile">-->
<!--        sf.id id,-->
<!--        sf.id file_id,-->
<!--        COALESCE(sf.user_id, '') user_id,-->
<!--        COALESCE(sf.category_id, '') category_id,-->
<!--        COALESCE(sfc.category_name, '') category_name,-->
<!--        sf.name name,-->
<!--        COALESCE(sf.file_local_path, '') file_local_path,-->
<!--        COALESCE(sf.file_remote_path, '') file_remote_path,-->
<!--        COALESCE(sf.file_remote_path_thumb, '') file_remote_path_thumb,-->
<!--        COALESCE(sf.file_key, '') file_key,-->
<!--        COALESCE(sf.size, '') size,-->
<!--        COALESCE(sf.md5, '') md5,-->
<!--        COALESCE(sf.chunk_upload_id, '') chunk_upload_id,-->
<!--        COALESCE(sf.chunk_count, '') chunk_count,-->
<!--        COALESCE(sf.chunk_current_index, '') chunk_current_index,-->
<!--        COALESCE(sf.notes, '') notes,-->
<!--        sf.create_time create_time,-->
<!--        sf.update_time update_time-->
<!--    </sql>-->

<!--&lt;!&ndash;    type="java.util.LinkedHashMap"&ndash;&gt;-->
<!--    <resultMap id="resultMapFile" type="com.backendsys.entity.System.SysFile.SysFileDTO">-->
<!--        <id property="id" column="id" jdbcType="BIGINT" />-->
<!--        <result property="file_id" column="file_id" javaType="java.lang.Long"/>-->
<!--        <result property="category_id" column="category_id" javaType="java.lang.Long"/>-->
<!--        <result property="category_name" column="category_name" />-->
<!--        <result property="user_id" column="user_id" javaType="java.lang.Long"/>-->
<!--        <result property="name" column="name" />-->
<!--        <result property="file_local_path" column="file_local_path" />-->
<!--        <result property="file_remote_path" column="file_remote_path" />-->
<!--        <result property="file_remote_path_thumb" column="file_remote_path_thumb" />-->
<!--        <result property="file_key" column="file_key" />-->
<!--        <result property="size" column="size" javaType="java.lang.Long"/>-->
<!--        <result property="md5" column="md5" />-->
<!--        <result property="chunk_upload_id" column="chunk_upload_id" />-->
<!--        <result property="chunk_count" column="chunk_count" javaType="java.lang.Integer"/>-->
<!--        <result property="chunk_current_index" column="chunk_current_index" javaType="java.lang.Integer"/>-->
<!--        <result property="notes" column="notes" />-->
<!--        <result property="create_time" column="create_time" />-->
<!--        <result property="update_time" column="update_time" />-->
<!--    </resultMap>-->


<!--    &lt;!&ndash; 查询 列表 &ndash;&gt;-->
<!--    <select id="queryFileList" resultMap="resultMapFile">-->
<!--        SELECT <include refid="includeFile" />-->
<!--        FROM sys_file sf-->
<!--        LEFT JOIN sys_file_category sfc ON sf.category_id = sfc.id-->
<!--        <where>-->
<!--            <if test="category_id != null and category_id != ''">-->
<!--                AND sf.category_id = #{category_id}-->
<!--            </if>-->
<!--            <if test="user_id != null and user_id != ''">-->
<!--                AND sf.user_id = #{user_id}-->
<!--            </if>-->
<!--            <if test="name != null and name != ''">-->
<!--                AND sf.name LIKE CONCAT('%', #{name}, '%')-->
<!--            </if>-->
<!--            <if test="md5 != null and md5 != ''">-->
<!--                AND sf.md5 = #{md5}-->
<!--            </if>-->
<!--            <if test="chunk_upload_id != null and chunk_upload_id != ''">-->
<!--                AND sf.chunk_upload_id = #{chunk_upload_id}-->
<!--            </if>-->
<!--        </where>-->
<!--        ORDER BY sf.create_time DESC-->
<!--    </select>-->
<!--    &lt;!&ndash; 查询 详情 &ndash;&gt;-->
<!--    <select id="queryFileByKey" resultMap="resultMapFile">-->
<!--        SELECT <include refid="includeFile" />-->
<!--        FROM sys_file sf-->
<!--        LEFT JOIN sys_file_category sfc ON sf.category_id = sfc.id-->
<!--        WHERE sf.file_key = #{file_key}-->
<!--    </select>-->

<!--    &lt;!&ndash; 创建 &ndash;&gt;-->
<!--    <insert id="insertFile" parameterType="com.backendsys.entity.System.SysFile.SysFileDTO"-->
<!--        useGeneratedKeys="true" keyProperty="file_id">-->
<!--        INSERT INTO sys_file (name-->
<!--            <if test="user_id != null and user_id != ''">, user_id</if>-->
<!--            <if test="category_id != null and category_id != ''">, category_id</if>-->
<!--            <if test="file_local_path != null and file_local_path != ''">, file_local_path</if>-->
<!--            <if test="file_remote_path != null and file_remote_path != ''">, file_remote_path</if>-->
<!--            <if test="file_remote_path_thumb != null and file_remote_path_thumb != ''">, file_remote_path_thumb</if>-->
<!--            <if test="file_key != null and file_key != ''">, file_key</if>-->
<!--            <if test="size != null and size != ''">, size</if>-->
<!--            <if test="md5 != null and md5 != ''">, md5</if>-->
<!--            <if test="chunk_upload_id != null and chunk_upload_id != ''">, chunk_upload_id</if>-->
<!--            <if test="chunk_count != null and chunk_count != ''">, chunk_count</if>-->
<!--            <if test="chunk_current_index != null and chunk_current_index != ''">, chunk_current_index</if>-->
<!--            <if test="notes != null and notes != ''">, notes</if>-->
<!--        ) VALUES (#{name}-->
<!--            <if test="user_id != null and user_id != ''">, #{user_id}</if>-->
<!--            <if test="category_id != null and category_id != ''">, #{category_id}</if>-->
<!--            <if test="file_local_path != null and file_local_path != ''">, #{file_local_path}</if>-->
<!--            <if test="file_remote_path != null and file_remote_path != ''">, #{file_remote_path}</if>-->
<!--            <if test="file_remote_path_thumb != null and file_remote_path_thumb != ''">, #{file_remote_path_thumb}</if>-->
<!--            <if test="file_key != null and file_key != ''">, #{file_key}</if>-->
<!--            <if test="size != null and size != ''">, #{size}</if>-->
<!--            <if test="md5 != null and md5 != ''">, #{md5}</if>-->
<!--            <if test="chunk_upload_id != null and chunk_upload_id != ''">, #{chunk_upload_id}</if>-->
<!--            <if test="chunk_count != null and chunk_count != ''">, #{chunk_count}</if>-->
<!--            <if test="chunk_current_index != null and chunk_current_index != ''">, #{chunk_current_index}</if>-->
<!--            <if test="notes != null and notes != ''">, #{notes}</if>-->
<!--        )-->
<!--    </insert>-->

<!--    &lt;!&ndash; 编辑 &ndash;&gt;-->
<!--    <update id="updateFile" parameterType="com.backendsys.entity.System.SysFile.SysFileDTO">-->
<!--        UPDATE sys_file SET-->
<!--            file_key = #{file_key},-->
<!--            chunk_count = #{chunk_count},-->
<!--            chunk_current_index = #{chunk_current_index}-->
<!--            <if test="name != null and name != ''">, name = #{name}</if>-->
<!--            <if test="category_id != null and category_id != ''">, category_id = #{category_id}</if>-->
<!--            <if test="user_id != null and user_id != ''">, user_id = #{user_id}</if>-->
<!--            <if test="file_local_path != null and file_local_path != ''">, file_local_path = #{file_local_path}</if>-->
<!--            <if test="file_remote_path != null and file_remote_path != ''">, file_remote_path = #{file_remote_path}</if>-->
<!--            <if test="file_remote_path_thumb != null and file_remote_path_thumb != ''">, file_remote_path_thumb = #{file_remote_path_thumb}</if>-->
<!--            <if test="file_key != null and file_key != ''">, file_key = #{file_key}</if>-->
<!--            <if test="size != null and size != ''">, size = #{size}</if>-->
<!--            <if test="md5 != null and md5 != ''">, md5 = #{md5}</if>-->
<!--            <if test="chunk_upload_id != null and chunk_upload_id != ''">, chunk_upload_id = #{chunk_upload_id}</if>-->
<!--            <if test="notes != null and notes != ''">, notes = #{notes}</if>-->
<!--        WHERE file_key = #{file_key}-->
<!--    </update>-->

<!--    &lt;!&ndash; 删除 &ndash;&gt;-->
<!--    <delete id="deleteFile" parameterType="java.lang.String">-->
<!--        DELETE FROM sys_file WHERE file_key = #{file_key};-->
<!--    </delete>-->

<!--</mapper>-->