<?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="cn.iocoder.yudao.module.jx.mapper.DriveSchoolFileMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolFile" id="DriveSchoolFileResult">
        <result property="id"    column="id"    />
        <result property="fileType"    column="file_type"    />
        <result property="deptId"    column="dept_id"    />
        <result property="fileAddress"    column="file_address"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
    </resultMap>

    <sql id="selectDriveSchoolFileVo">
        select id, dept_id,file_type, file_address, create_time, creator, update_time, updater from drive_school_file
    </sql>

    <select id="selectDriveSchoolFileList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFile" resultMap="DriveSchoolFileResult">
        <include refid="selectDriveSchoolFileVo"/>
        <where>
            deleted = 0
            <if test="entity.fileType != null  and entity.fileType != ''"> and file_type = #{entity.fileType}</if>
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.fileAddress != null  and entity.fileAddress != ''"> and file_address = #{entity.fileAddress}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolFileListAll" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFile" resultMap="DriveSchoolFileResult">
        <include refid="selectDriveSchoolFileVo"/>
        <where>
            deleted = 0
            <if test="entity.fileType != null  and entity.fileType != ''"> and file_type = #{entity.fileType}</if>
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.fileAddress != null  and entity.fileAddress != ''"> and file_address = #{entity.fileAddress}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolFileById" parameterType="Long" resultMap="DriveSchoolFileResult">
        <include refid="selectDriveSchoolFileVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolFile" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFile" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileType != null and fileType != ''">file_type,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="fileAddress != null and fileAddress != ''">file_address,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileType != null and fileType != ''">#{fileType},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="fileAddress != null and fileAddress != ''">#{fileAddress},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
         </trim>
    </insert>

    <update id="updateDriveSchoolFile" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFile">
        update drive_school_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileType != null and fileType != ''">file_type = #{fileType},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="fileAddress != null and fileAddress != ''">file_address = #{fileAddress},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveSchoolFileById" parameterType="Long">
        delete from drive_school_file where id = #{id}
    </delete>

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

    <select id="getOneFile" parameterType="Long" resultMap="DriveSchoolFileResult">
        <include refid="selectDriveSchoolFileVo"/>
        <where>
            deleted = 0
            <if test="fileType != null  and fileType != ''"> and file_type = #{fileType}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="fileAddress != null  and fileAddress != ''"> and file_address = #{fileAddress}</if>
        </where>
    </select>
</mapper>
