<?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.goldenwater.yjjt.mapper.YjjtFileMapper">

    <resultMap type="com.goldenwater.yjjt.domain.YjjtFile" id="YjjtFileResult">
        <id     property="id"             column="id"              />
        <result property="fileViewname"   column="file_viewname"   />
        <result property="fileSavename"   column="file_savename"   />
        <result property="filePath"       column="file_path"       />
        <result property="fileSize"       column="file_size"       />
        <result property="fileType"       column="file_type"       />
        <result property="bizType"        column="biz_type"        />
        <result property="uploadBy"       column="upload_by"       />
        <result property="uploadTime"     column="upload_time"     />
        <result property="status"         column="status"          />
        <result property="remark"         column="remark"          />
        <result property="createBy"       column="create_by"       />
        <result property="createTime"     column="create_time"     />
        <result property="updateBy"       column="update_by"       />
        <result property="updateTime"     column="update_time"     />
    </resultMap>

    <insert id="insertYjjtFile" parameterType="com.goldenwater.yjjt.domain.YjjtFile" useGeneratedKeys="true" keyProperty="id">
        insert into YJJT_FILE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileViewname != null">file_viewname,</if>
            <if test="fileSavename != null">file_savename,</if>
            <if test="filePath != null">file_path,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="fileType != null">file_type,</if>
            <if test="bizType != null">biz_type,</if>
            <if test="uploadBy != null">upload_by,</if>
            upload_time,
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileViewname != null">#{fileViewname},</if>
            <if test="fileSavename != null">#{fileSavename},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="fileType != null">#{fileType},</if>
            <if test="bizType != null">#{bizType},</if>
            <if test="uploadBy != null">#{uploadBy},</if>
            SYSDATE,
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            SYSDATE
        </trim>
    </insert>

    <select id="selectYjjtFileList" parameterType="com.goldenwater.yjjt.domain.YjjtFile" resultMap="YjjtFileResult">
        select id, file_viewname, file_savename, file_path, file_size, file_type, biz_type, upload_by, upload_time, status, remark, create_by, create_time, update_by, update_time
        from YJJT_FILE
        where status = '0'
        <if test="fileViewname != null and fileViewname != ''">
            and file_viewname like concat('%', #{fileViewname}, '%')
        </if>
        <if test="fileType != null and fileType != ''">
            and file_type = #{fileType}
        </if>
        <if test="bizType != null and bizType != ''">
            and biz_type = #{bizType}
        </if>
        order by upload_time desc
    </select>

    <select id="selectYjjtFileById" parameterType="Long" resultMap="YjjtFileResult">
        select id, file_viewname, file_savename, file_path, file_size, file_type, biz_type, upload_by, upload_time, status, remark, create_by, create_time, update_by, update_time
        from YJJT_FILE
        where id = #{id}
    </select>

    <delete id="deleteYjjtFileById" parameterType="Long">
        delete from YJJT_FILE where id = #{id}
    </delete>

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