<?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.steerinfo.ftp.uploadfile.mapper.UploadFileMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ftp.uploadfile.model.UploadFile">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="FILE_NAME" jdbcType="VARCHAR" property="fileName" />
    <result column="FILE_URL" jdbcType="VARCHAR" property="fileUrl" />
    <result column="TYPE" jdbcType="VARCHAR" property="type" />
    <result column="FILE_TYPE" jdbcType="VARCHAR" property="fileType" />
    <result column="UPLOAD_TIME" jdbcType="TIMESTAMP" property="uploadTime" />
    <result column="CREATE_MAN" jdbcType="VARCHAR" property="createMan" />
    <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
    <result column="UPDATE_MAN" jdbcType="VARCHAR" property="updateMan" />
    <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="EXPLAIN" jdbcType="VARCHAR" property="explain" />
    <result column="MEMO" jdbcType="VARCHAR" property="memo" />
  </resultMap>
  <sql id="columns">
    ID, FILE_NAME, FILE_URL, TYPE, UPLOAD_TIME, CREATE_MAN, CREATE_TIME, UPDATE_MAN, 
    UPDATE_TIME, FILE_TYPE,EXPLAIN,MEMO
  </sql>
  <sql id="columns_alias">
    t.ID, t.FILE_NAME, t.FILE_URL, t.TYPE, t.UPLOAD_TIME, t.CREATE_MAN, t.CREATE_TIME, 
    t.UPDATE_MAN, t.UPDATE_TIME, t.FILE_TYPE,t.EXPLAIN,t.MEMO
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM UPLOAD_FILE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM UPLOAD_FILE t
  </sql>
  <sql id="where">
    <where> 
      <if test="id != null and id != ''">
        and ID = #{id}
      </if>
      <if test="fileName != null and fileName != ''">
        and FILE_NAME = #{fileName}
      </if>
      <if test="fileUrl != null and fileUrl != ''">
        and FILE_URL = #{fileUrl}
      </if>
      <if test="type != null and type != ''">
        and TYPE = #{type}
      </if>
      <if test="uploadTime != null">
        and TO_CHAR(UPLOAD_TIME,'yyyy-MM-dd') = #{uploadTime}
      </if>
      <if test="createMan != null and createMan != ''">
        and CREATE_MAN = #{createMan}
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="updateMan != null and updateMan != ''">
        and UPDATE_MAN = #{updateMan}
      </if>
      <if test="updateTime != null">
        and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
      </if>
      <if test="fileType != null and fileType != ''">
        and FILE_TYPE = #{fileType}
      </if>
      <if test="explain != null and explain != ''">
        and EXPLAIN = #{explain}
      </if>
      <if test="memo != null and memo != ''">
        and MEMO = #{memo}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="securityInfo != null and securityInfo != ''">
        and (SECURITY_INFO is null
        OR SECURITY_INFO = ''
        OR REGEXP_LIKE(SECURITY_INFO,'(${securityInfo})'))
      </if>
      <if test="id != null and id != ''">
        and ID LIKE '%${id}%'
      </if>
      <if test="fileName != null and fileName != ''">
        and FILE_NAME LIKE '%${fileName}%'
      </if>
      <if test="fileUrl != null and fileUrl != ''">
        and FILE_URL LIKE '%${fileUrl}%'
      </if>
      <if test="type != null and type != ''">
        and TYPE LIKE '%${type}%'
      </if>
      <if test="uploadTime != null">
        and TO_CHAR(UPLOAD_TIME,'yyyy-MM-dd') = #{uploadTime}
      </if>
      <if test="createMan != null and createMan != ''">
        and CREATE_MAN LIKE '%${createMan}%'
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="updateMan != null and updateMan != ''">
        and UPDATE_MAN LIKE '%${updateMan}%'
      </if>
      <if test="updateTime != null">
        and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
      </if>
      <if test="fileType != null and fileType != ''">
<!--        and FILE_TYPE is null-->
<!--        OR FILE_TYPE = ''-->
        AND REGEXP_LIKE(FILE_TYPE,'(${fileType})')
      </if>
      <if test="explain != null and explain != ''">
        and EXPLAIN LIKE '%${explain}%'
      </if>
      <if test="memo != null and memo != ''">
        and MEMO LIKE '%${memo}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from UPLOAD_FILE
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from UPLOAD_FILE
    where 1!=1 
      <if test="fileName != null and fileName != ''">
        or FILE_NAME = #{fileName}
      </if>
      <if test="fileUrl != null and fileUrl != ''">
        or FILE_URL = #{fileUrl}
      </if>
      <if test="type != null and type != ''">
        or TYPE = #{type}
      </if>
      <if test="uploadTime != null">
        or TO_CHAR(UPLOAD_TIME,'yyyy-MM-dd') = '#{uploadTime}'
      </if>
      <if test="createMan != null and createMan != ''">
        or CREATE_MAN = #{createMan}
      </if>
      <if test="createTime != null">
        or TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = '#{createTime}'
      </if>
      <if test="updateMan != null and updateMan != ''">
        or UPDATE_MAN = #{updateMan}
      </if>
      <if test="updateTime != null">
        or TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = '#{updateTime}'
      </if>
      <if test="explain != null and explain != ''">
        or EXPLAIN = #{explain}
      </if>
      <if test="memo != null and memo != ''">
        or MEMO = #{memo}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ftp.uploadfile.model.UploadFile">
    insert into UPLOAD_FILE (ID, FILE_NAME, FILE_URL, 
      TYPE, UPLOAD_TIME, CREATE_MAN, 
      CREATE_TIME, UPDATE_MAN, UPDATE_TIME,FILE_TYPE,EXPLAIN,MEMO
      )
    values (#{id,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, #{fileUrl,jdbcType=VARCHAR}, 
      #{type,jdbcType=VARCHAR}, #{uploadTime,jdbcType=TIMESTAMP}, #{createMan,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{updateMan,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
      #{fileType,jdbcType=VARCHAR},#{explain,jdbcType=VARCHAR},#{memo,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ftp.uploadfile.model.UploadFile">
    insert into UPLOAD_FILE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="fileName != null">
        FILE_NAME,
      </if>
      <if test="fileUrl != null">
        FILE_URL,
      </if>
      <if test="fileType != null">
        FILE_TYPE,
      </if>
      <if test="type != null">
        TYPE,
      </if>
      <if test="uploadTime != null">
        UPLOAD_TIME,
      </if>
      <if test="createMan != null">
        CREATE_MAN,
      </if>
      <if test="createTime != null">
        CREATE_TIME,
      </if>
      <if test="updateMan != null">
        UPDATE_MAN,
      </if>
      <if test="updateTime != null">
        UPDATE_TIME,
      </if>
      <if test="explain != null">
        EXPLAIN,
      </if>
      <if test="memo != null">
        MEMO,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="fileName != null">
        #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="fileUrl != null">
        #{fileUrl,jdbcType=VARCHAR},
      </if>
      <if test="fileType != null">
        #{fileType,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="uploadTime != null">
        #{uploadTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createMan != null">
        #{createMan,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateMan != null">
        #{updateMan,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="explain != null">
        #{explain,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        #{memo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ftp.uploadfile.model.UploadFile">
    update UPLOAD_FILE
    set FILE_NAME = #{fileName,jdbcType=VARCHAR},
      FILE_URL = #{fileUrl,jdbcType=VARCHAR},
      TYPE = #{type,jdbcType=VARCHAR},
      UPLOAD_TIME = #{uploadTime,jdbcType=TIMESTAMP},
      CREATE_MAN = #{createMan,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      UPDATE_MAN = #{updateMan,jdbcType=VARCHAR},
      UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
    EXPLAIN = #{explain,jdbcType=VARCHAR},
    MEMO = #{memo,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ftp.uploadfile.model.UploadFile">
    update UPLOAD_FILE
    <set>
      <if test="fileName != null">
        FILE_NAME = #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="fileUrl != null">
        FILE_URL = #{fileUrl,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        TYPE = #{type,jdbcType=VARCHAR},
      </if>
      <if test="uploadTime != null">
        UPLOAD_TIME = #{uploadTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createMan != null">
        CREATE_MAN = #{createMan,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateMan != null">
        UPDATE_MAN = #{updateMan,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="fileType != null">
        FILE_TYPE = #{fileType,jdbcType=VARCHAR},
      </if>
      <if test="explain != null">
        EXPLAIN = #{explain,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        MEMO = #{memo,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select_alias"/>
    LEFT JOIN SECURITY_TYPE s ON s.ID = t.TYPE
    <include refid="whereLike"/>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into UPLOAD_FILE 
      (ID, 
      FILE_NAME, FILE_URL, TYPE, 
      UPLOAD_TIME, CREATE_MAN, CREATE_TIME, 
      UPDATE_MAN, UPDATE_TIME, EXPLAIN,MEMO)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.fileName,jdbcType=VARCHAR}, #{item.fileUrl,jdbcType=VARCHAR}, #{item.type,jdbcType=VARCHAR}, 
      #{item.uploadTime,jdbcType=TIMESTAMP}, #{item.createMan,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
      #{item.updateMan,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.explain,jdbcType=VARCHAR}, #{item.memo,jdbcType=VARCHAR} from dual
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update UPLOAD_FILE
     set
       ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.id,jdbcType=VARCHAR}
       </foreach>
       ,FILE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.fileName,jdbcType=VARCHAR}
       </foreach>
       ,FILE_URL=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.fileUrl,jdbcType=VARCHAR}
       </foreach>
       ,TYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.type,jdbcType=VARCHAR}
       </foreach>
       ,UPLOAD_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.uploadTime,jdbcType=TIMESTAMP}
       </foreach>
       ,CREATE_MAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.createMan,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
       ,UPDATE_MAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.updateMan,jdbcType=VARCHAR}
       </foreach>
       ,UPDATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=TIMESTAMP}
       </foreach>
    ,EXPLAIN=
    <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
      when #{item.id,jdbcType=VARCHAR} then #{item.explain,jdbcType=VARCHAR}
    </foreach>
    ,MEMO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
      when #{item.id,jdbcType=VARCHAR} then #{item.memo,jdbcType=VARCHAR}
    </foreach>
     where ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.id,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from UPLOAD_FILE
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="getIdAndName" resultMap="BaseResultMap">
    select distinct  ID, FILE_NAME  FROM  UPLOAD_FILE
  </select>
  <select id="getTag" resultMap="BaseResultMap">
    select distinct FILE_TYPE FROM UPLOAD_FILE
  </select>
  <select id="getTreeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    SELECT s.ID as TYPE,s.SECURITY_NAME AS CREATE_MAN,s.SECURITY_PARENTID AS UPDATE_MAN,
    t.ID,t.FILE_NAME,t.FILE_URL FROM SECURITY_TYPE s
    LEFT JOIN UPLOAD_FILE t ON s.ID = t.TYPE
    <include refid="whereLike"/>
    order by SECURITY_NODE,SEQNO,CREATE_MAN
  </select>
</mapper>