<?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.vetti.hotake.mapper.HotakeSysFileMapper">

    <resultMap type="HotakeSysFile" id="HotakeSysFileResult">
        <result property="id"    column="id"    />
        <result property="minioBucketName"    column="minio_bucket_name"    />
        <result property="code"    column="code"    />
        <result property="fileName"    column="file_name"    />
        <result property="fileType"    column="file_type"    />
        <result property="fileSize"    column="file_size"    />
        <result property="storagePath"    column="storage_path"    />
        <result property="fileMd5"    column="file_md5"    />
        <result property="uploadPlatform"    column="upload_platform"    />
        <result property="available"    column="available"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectHotakeSysFileVo">
        select id, minio_bucket_name, code, file_name, file_type, file_size, storage_path, file_md5, upload_platform, available, create_by, create_time, update_by, update_time, remark from hotake_sys_file
    </sql>

    <select id="selectHotakeSysFileList" parameterType="HotakeSysFile" resultMap="HotakeSysFileResult">
        <include refid="selectHotakeSysFileVo"/>
        <where>
            <if test="minioBucketName != null  and minioBucketName != ''"> and minio_bucket_name = #{minioBucketName}</if>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="fileType != null  and fileType != ''"> and file_type = #{fileType}</if>
            <if test="fileSize != null "> and file_size = #{fileSize}</if>
            <if test="storagePath != null  and storagePath != ''"> and storage_path = #{storagePath}</if>
            <if test="fileMd5 != null  and fileMd5 != ''"> and file_md5 = #{fileMd5}</if>
            <if test="uploadPlatform != null "> and upload_platform = #{uploadPlatform}</if>
            <if test="available != null "> and available = #{available}</if>
        </where>
    </select>

    <select id="selectHotakeSysFileById" parameterType="Long" resultMap="HotakeSysFileResult">
        <include refid="selectHotakeSysFileVo"/>
        where id = #{id}
    </select>

    <insert id="insertHotakeSysFile" parameterType="HotakeSysFile" useGeneratedKeys="true" keyProperty="id">
        insert into Hotake_sys_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="minioBucketName != null and minioBucketName != ''">minio_bucket_name,</if>
            <if test="code != null and code != ''">code,</if>
            <if test="fileName != null and fileName != ''">file_name,</if>
            <if test="fileType != null and fileType != ''">file_type,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="storagePath != null and storagePath != ''">storage_path,</if>
            <if test="fileMd5 != null">file_md5,</if>
            <if test="uploadPlatform != null">upload_platform,</if>
            <if test="available != null">available,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="minioBucketName != null and minioBucketName != ''">#{minioBucketName},</if>
            <if test="code != null and code != ''">#{code},</if>
            <if test="fileName != null and fileName != ''">#{fileName},</if>
            <if test="fileType != null and fileType != ''">#{fileType},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="storagePath != null and storagePath != ''">#{storagePath},</if>
            <if test="fileMd5 != null">#{fileMd5},</if>
            <if test="uploadPlatform != null">#{uploadPlatform},</if>
            <if test="available != null">#{available},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateHotakeSysFile" parameterType="HotakeSysFile">
        update Hotake_sys_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="minioBucketName != null and minioBucketName != ''">minio_bucket_name = #{minioBucketName},</if>
            <if test="code != null and code != ''">code = #{code},</if>
            <if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
            <if test="fileType != null and fileType != ''">file_type = #{fileType},</if>
            <if test="fileSize != null">file_size = #{fileSize},</if>
            <if test="storagePath != null and storagePath != ''">storage_path = #{storagePath},</if>
            <if test="fileMd5 != null">file_md5 = #{fileMd5},</if>
            <if test="uploadPlatform != null">upload_platform = #{uploadPlatform},</if>
            <if test="available != null">available = #{available},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteHotakeSysFileById" parameterType="Long">
        delete from Hotake_sys_file where id = #{id}
    </delete>

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

    <insert id="batchInsertHotakeSysFile">
        insert into Hotake_sys_file( id, minio_bucket_name, code, file_name, file_type, file_size, storage_path, file_md5, upload_platform, available, create_by, create_time, update_by, update_time, remark,) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.id}, #{item.minioBucketName}, #{item.code}, #{item.fileName}, #{item.fileType}, #{item.fileSize}, #{item.storagePath}, #{item.fileMd5}, #{item.uploadPlatform}, #{item.available}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark},)
        </foreach>
    </insert>

    <select id="selectHotakeSysFileByIds" parameterType="String" resultMap="HotakeSysFileResult">
        <include refid="selectHotakeSysFileVo"/> where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

</mapper>