<?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.ems.tmaintenancefile.mapper.TMaintenanceFileMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tmaintenancefile.model.TMaintenanceFile">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="FILENAME" jdbcType="VARCHAR" property="filename" />
    <result column="FILEPATH" jdbcType="VARCHAR" property="filepath" />
  </resultMap>
  <sql id="columns">
    ID, FILENAME, FILEPATH
  </sql>
  <sql id="columns_alias">
    t.ID, t.FILENAME, t.FILEPATH
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_MAINTENANCE_FILE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_MAINTENANCE_FILE t
  </sql>
  <sql id="where">
    <where> 
      <if test="id != null and id != ''">
        and ID = #{id}
      </if>
      <if test="filename != null and filename != ''">
        and FILENAME = #{filename}
      </if>
      <if test="filepath != null and filepath != ''">
        and FILEPATH = #{filepath}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="id != null and id != ''">
        and ID LIKE '%${id}%'
      </if>
      <if test="filename != null and filename != ''">
        and FILENAME LIKE '%${filename}%'
      </if>
      <if test="filepath != null and filepath != ''">
        and FILEPATH LIKE '%${filepath}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_MAINTENANCE_FILE
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_MAINTENANCE_FILE
    where 1!=1 
      <if test="filename != null and filename != ''">
        or FILENAME = #{filename}
      </if>
      <if test="filepath != null and filepath != ''">
        or FILEPATH = #{filepath}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tmaintenancefile.model.TMaintenanceFile">
    insert into T_MAINTENANCE_FILE (ID, FILENAME, FILEPATH
      )
    values (#{id,jdbcType=VARCHAR}, #{filename,jdbcType=VARCHAR}, #{filepath,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tmaintenancefile.model.TMaintenanceFile">
    insert into T_MAINTENANCE_FILE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="filename != null">
        FILENAME,
      </if>
      <if test="filepath != null">
        FILEPATH,
      </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="filepath != null">
        #{filepath,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tmaintenancefile.model.TMaintenanceFile">
    update T_MAINTENANCE_FILE
    set FILENAME = #{filename,jdbcType=VARCHAR},
      FILEPATH = #{filepath,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tmaintenancefile.model.TMaintenanceFile">
    update T_MAINTENANCE_FILE
    <set>
      <if test="filename != null">
        FILENAME = #{filename,jdbcType=VARCHAR},
      </if>
      <if test="filepath != null">
        FILEPATH = #{filepath,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"/>
    <include refid="whereLike"/>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_MAINTENANCE_FILE 
      (ID, 
      FILENAME, FILEPATH)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.filename,jdbcType=VARCHAR}, #{item.filepath,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_MAINTENANCE_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>
       ,FILENAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.filename,jdbcType=VARCHAR}
       </foreach>
       ,FILEPATH=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.filepath,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 T_MAINTENANCE_FILE
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="getlist" parameterType="string" resultType="com.steerinfo.ems.tmaintenancefile.model.TMaintenanceFile">
     select * from T_MAINTENANCE_FILE where ID = #{id}
  </select>
  <select id="getlists" parameterType="string" resultType="com.steerinfo.ems.tmaintenancefile.model.TMaintenanceFile">
    select * from T_MAINTENANCE_FILE where ID = #{id}
  </select>
  <delete id="delFile" parameterType="string">
    delete from T_MAINTENANCE_FILE
    where FILEPATH = #{filepath,jdbcType=VARCHAR}
  </delete>
</mapper>