<?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.jeethink.system.mapper.SystemFileMapper">
    
    <resultMap type="SystemFile" id="SystemFileResult">
        <result property="fileId"    column="FILE_ID"    />
        <result property="fileName"    column="FILE_NAME"    />
        <result property="fileSuffix"    column="FILE_SUFFIX"    />
        <result property="fileSize"    column="FILE_SIZE"    />
        <result property="filePath"    column="FILE_PATH"    />
        <result property="fileUrl"    column="FILE_URL"    />
        <result property="fileObjectId"    column="FILE_OBJECT_ID"    />
        <result property="fileObjectDatabase"    column="FILE_OBJECT_DATABASE"    />
        <result property="fileDeleteType"    column="FILE_DELETE_TYPE"    />
        <result property="fileDeleteTime"    column="FILE_DELETE_TIME"    />
        <result property="createUserId"    column="CREATE_USER_ID"    />
        <result property="fileCreateTime"    column="FILE_CREATE_TIME"    />
        <result property="modifyUserId"    column="MODIFY_USER_ID"    />
        <result property="fileModifyTime"    column="FILE_MODIFY_TIME"    />
        <result property="fileType"    column="FILE_TYPE"    />
        <result property="fileOccurTime"    column="FILE_OCCUR_TIME"    />
    </resultMap>

    <sql id="selectSystemFileVo">
        select FILE_ID, FILE_NAME, FILE_SUFFIX, FILE_SIZE, FILE_PATH, FILE_URL, FILE_OBJECT_ID, FILE_OBJECT_DATABASE, FILE_DELETE_TYPE, FILE_DELETE_TIME,
               CREATE_USER_ID, FILE_CREATE_TIME, MODIFY_USER_ID, FILE_MODIFY_TIME, FILE_TYPE,FILE_OCCUR_TIME from system_file
    </sql>

    <select id="selectSystemFileList" parameterType="SystemFile" resultMap="SystemFileResult">
        <include refid="selectSystemFileVo"/>
        <where>  
            <if test="fileName != null  and fileName != ''"> and FILE_NAME like concat('%', #{fileName}, '%')</if>
            <if test="fileSuffix != null  and fileSuffix != ''"> and FILE_SUFFIX = #{fileSuffix}</if>
            <if test="fileSize != null "> and FILE_SIZE = #{fileSize}</if>
            <if test="filePath != null  and filePath != ''"> and FILE_PATH = #{filePath}</if>
            <if test="fileUrl != null  and fileUrl != ''"> and FILE_URL = #{fileUrl}</if>
            <if test="fileObjectId != null  and fileObjectId != ''"> and FILE_OBJECT_ID = #{fileObjectId}</if>
            <if test="fileObjectDatabase != null  and fileObjectDatabase != ''"> and FILE_OBJECT_DATABASE = #{fileObjectDatabase}</if>
            <if test="fileDeleteType != null  and fileDeleteType != ''"> and FILE_DELETE_TYPE = #{fileDeleteType}</if>
            <if test="fileDeleteTime != null "> and FILE_DELETE_TIME = #{fileDeleteTime}</if>
            <if test="createUserId != null "> and CREATE_USER_ID = #{createUserId}</if>
            <if test="fileCreateTime != null "> and FILE_CREATE_TIME = #{fileCreateTime}</if>
            <if test="modifyUserId != null "> and MODIFY_USER_ID = #{modifyUserId}</if>
            <if test="fileModifyTime != null "> and FILE_MODIFY_TIME = #{fileModifyTime}</if>
            <if test="fileType != null  and fileType != ''"> and FILE_TYPE = #{fileType}</if>
        </where>
        order by FILE_NAME
    </select>
    
    <select id="selectSystemFileById" parameterType="String" resultMap="SystemFileResult">
        <include refid="selectSystemFileVo"/>
        where FILE_ID = #{fileId}
    </select>
        
    <insert id="insertSystemFile" parameterType="SystemFile">
        insert into system_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileId != null">FILE_ID,</if>
            <if test="fileName != null">FILE_NAME,</if>
            <if test="fileSuffix != null">FILE_SUFFIX,</if>
            <if test="fileSize != null">FILE_SIZE,</if>
            <if test="filePath != null">FILE_PATH,</if>
            <if test="fileUrl != null">FILE_URL,</if>
            <if test="fileObjectId != null">FILE_OBJECT_ID,</if>
            <if test="fileObjectDatabase != null">FILE_OBJECT_DATABASE,</if>
            <if test="fileDeleteType != null">FILE_DELETE_TYPE,</if>
            <if test="fileDeleteTime != null">FILE_DELETE_TIME,</if>
            <if test="createUserId != null">CREATE_USER_ID,</if>
            <if test="fileCreateTime != null">FILE_CREATE_TIME,</if>
            <if test="modifyUserId != null">MODIFY_USER_ID,</if>
            <if test="fileModifyTime != null">FILE_MODIFY_TIME,</if>
            <if test="fileType != null">FILE_TYPE,</if>
            <if test="fileOccurTime != null">FILE_OCCUR_TIME,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileId != null">#{fileId},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="fileSuffix != null">#{fileSuffix},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="fileObjectId != null">#{fileObjectId},</if>
            <if test="fileObjectDatabase != null">#{fileObjectDatabase},</if>
            <if test="fileDeleteType != null">#{fileDeleteType},</if>
            <if test="fileDeleteTime != null">#{fileDeleteTime},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="fileCreateTime != null">#{fileCreateTime},</if>
            <if test="modifyUserId != null">#{modifyUserId},</if>
            <if test="fileModifyTime != null">#{fileModifyTime},</if>
            <if test="fileType != null">#{fileType},</if>
            <if test="fileOccurTime != null">#{fileOccurTime},</if>
         </trim>
    </insert>

    <update id="updateSystemFile" parameterType="SystemFile">
        update system_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileName != null">FILE_NAME = #{fileName},</if>
            <if test="fileSuffix != null">FILE_SUFFIX = #{fileSuffix},</if>
            <if test="fileSize != null">FILE_SIZE = #{fileSize},</if>
            <if test="filePath != null">FILE_PATH = #{filePath},</if>
            <if test="fileUrl != null">FILE_URL = #{fileUrl},</if>
            <if test="fileObjectId != null">FILE_OBJECT_ID = #{fileObjectId},</if>
            <if test="fileObjectDatabase != null">FILE_OBJECT_DATABASE = #{fileObjectDatabase},</if>
            <if test="fileDeleteType != null">FILE_DELETE_TYPE = #{fileDeleteType},</if>
            <if test="fileDeleteTime != null">FILE_DELETE_TIME = #{fileDeleteTime},</if>
            <if test="createUserId != null">CREATE_USER_ID = #{createUserId},</if>
            <if test="fileCreateTime != null">FILE_CREATE_TIME = #{fileCreateTime},</if>
            <if test="modifyUserId != null">MODIFY_USER_ID = #{modifyUserId},</if>
            <if test="fileModifyTime != null">FILE_MODIFY_TIME = #{fileModifyTime},</if>
            <if test="fileType != null">FILE_TYPE = #{fileType},</if>
            <if test="fileOccurTime != null">FILE_OCCUR_TIME = #{fileOccurTime},</if>
        </trim>
        where FILE_ID = #{fileId}
    </update>

    <delete id="deleteSystemFileById" parameterType="String">
        delete from system_file where FILE_ID = #{fileId}
    </delete>

    <delete id="deleteSystemFileByIds" parameterType="String">
        delete from system_file where FILE_ID in 
        <foreach item="fileId" collection="array" open="(" separator="," close=")">
            #{fileId}
        </foreach>
    </delete>
    
</mapper>