<?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.SysDeptfileMapper">
    
    <resultMap type="SysDeptfile" id="SysDeptfileResult">
        <result property="id"    column="id"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="fileName"    column="file_name"    />
        <result property="fileSize"    column="file_size"    />
        <result property="originalFilename"    column="original_filename"    />
        <result property="createTime"    column="createtime"    />
    </resultMap>

    <sql id="selectSysDeptfileVo">
        select id, file_url, file_name, file_size, original_filename, createtime from sys_deptfile
    </sql>

    <select id="selectSysDeptfileList" parameterType="SysDeptfile" resultMap="SysDeptfileResult">
        <include refid="selectSysDeptfileVo"/>
        <where>  
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="fileSize != null "> and file_size = #{fileSize}</if>
            <if test="originalFilename != null  and originalFilename != ''"> and original_filename like concat('%', #{originalFilename}, '%')</if>
            <if test="createTime != null "> and createtime = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectSysDeptfileById" parameterType="Long" resultMap="SysDeptfileResult">
        <include refid="selectSysDeptfileVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysDeptfile" parameterType="SysDeptfile" useGeneratedKeys="true" keyProperty="id">
        insert into sys_deptfile
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileUrl != null">file_url,</if>
            <if test="fileName != null">file_name,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="originalFilename != null">original_filename,</if>
            <if test="createTime != null">createtime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="originalFilename != null">#{originalFilename},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSysDeptfile" parameterType="SysDeptfile">
        update sys_deptfile
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="fileSize != null">file_size = #{fileSize},</if>
            <if test="originalFilename != null">original_filename = #{originalFilename},</if>
            <if test="createTime != null">createtime = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysDeptfileById" parameterType="Long">
        delete from sys_deptfile where id = #{id}
    </delete>

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