<?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="fileTime"      column="file_time"      />
        <result property="filePath"      column="file_path"      />
        <result property="fileSize"      column="file_size"      />
        <result property="fileType"      column="file_type"      />
        <result property="userName"      column="user_name"      />
        <result property="userId"        column="user_id"        />
        <result property="isSync"        column="is_sync"        />
        <result property="bizType"       column="biz_type"       />
        <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"         />
        <result property="delFlag"       column="del_flag"       />
    </resultMap>

    <sql id="selectFileVo">
        select id, file_viewname, file_savename, file_time, file_path, file_size,
               file_type, user_name, user_id, is_sync, biz_type,
               create_by, create_time, update_by, update_time, remark, del_flag
        from gx_yjjt_file
    </sql>

    <select id="selectYjjtFileList" parameterType="com.goldenwater.yjjt.domain.YjjtFile" resultMap="YjjtFileResult">
        <include refid="selectFileVo"/>
        where del_flag = '0'
        <if test="fileViewname != null and fileViewname != ''">
            AND file_viewname like '%' || #{fileViewname} || '%'
        </if>
        <if test="bizType != null and bizType != ''">
            AND biz_type = #{bizType}
        </if>
        <if test="userName != null and userName != ''">
            AND user_name like '%' || #{userName} || '%'
        </if>
        <if test="userId != null">
            AND user_id = #{userId}
        </if>
        order by file_time desc
    </select>

    <select id="selectYjjtFileById" parameterType="Long" resultMap="YjjtFileResult">
        <include refid="selectFileVo"/>
        where id = #{id} and del_flag = '0'
    </select>

    <insert id="insertYjjtFile" parameterType="com.goldenwater.yjjt.domain.YjjtFile" useGeneratedKeys="true" keyProperty="id">
        insert into gx_yjjt_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileViewname != null and fileViewname != ''">file_viewname,</if>
            <if test="fileSavename != null and fileSavename != ''">file_savename,</if>
            <if test="fileTime != null">file_time,</if>
            <if test="filePath != null">file_path,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="fileType != null">file_type,</if>
            <if test="userName != null">user_name,</if>
            <if test="userId != null">user_id,</if>
            <if test="isSync != null">is_sync,</if>
            <if test="bizType != null">biz_type,</if>
            <if test="createBy != null">create_by,</if>
            <if test="remark != null">remark,</if>
            del_flag, create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileViewname != null and fileViewname != ''">#{fileViewname},</if>
            <if test="fileSavename != null and fileSavename != ''">#{fileSavename},</if>
            <if test="fileTime != null">#{fileTime},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="fileType != null">#{fileType},</if>
            <if test="userName != null">#{userName},</if>
            <if test="userId != null">#{userId},</if>
            <if test="isSync != null">#{isSync},</if>
            <if test="bizType != null">#{bizType},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="remark != null">#{remark},</if>
            '0', SYSDATE
        </trim>
    </insert>

    <update id="deleteYjjtFileById" parameterType="Long">
        update gx_yjjt_file set del_flag = '1' where id = #{id}
    </update>

    <update id="deleteYjjtFileByIds" parameterType="Long">
        update gx_yjjt_file set del_flag = '1' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

</mapper>
