<?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.emslog.mapper.EmsLogMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.emslog.model.EmsLog">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="UPDATETABLE" jdbcType="VARCHAR" property="updatetable" />
    <result column="CODE" jdbcType="VARCHAR" property="code" />
    <result column="OPERATORTIME" jdbcType="TIMESTAMP" property="operatortime" />
    <result column="OPERATOR" jdbcType="VARCHAR" property="operator" />
    <result column="TYPE" jdbcType="VARCHAR" property="type"/>
    <result column="PAGE" jdbcType="VARCHAR" property="page"/>
  </resultMap>
  <sql id="columns">
    ID, UPDATETABLE, CODE, OPERATORTIME, OPERATOR, TYPE, PAGE
  </sql>
  <sql id="columns_alias">
    t.ID, t.UPDATETABLE, t.CODE, t.OPERATORTIME, t.OPERATOR
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM EMS_LOG
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM EMS_LOG t
  </sql>
  <sql id="where">
    <where> 
      <if test="id != null and id != ''">
        and ID = #{id}
      </if>
      <if test="updatetable != null and updatetable != ''">
        and UPDATETABLE = #{updatetable}
      </if>
      <if test="code != null and code != ''">
        and CODE = #{code}
      </if>
      <if test="operatortime != null">
        and TO_CHAR(OPERATORTIME,'yyyy-MM-dd') = #{operatortime}
      </if>
      <if test="operator != null and operator != ''">
        and OPERATOR = #{operator}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="id != null and id != ''">
        and ID LIKE '%${id}%'
      </if>
      <if test="updatetable != null and updatetable != ''">
        and UPDATETABLE LIKE '%${updatetable}%'
      </if>
      <if test="code != null and code != ''">
        and CODE LIKE '%${code}%'
      </if>
      <if test="operatortime != null">
        and TO_CHAR(OPERATORTIME,'yyyy-MM-dd') = #{operatortime}
      </if>
      <if test="operator != null and operator != ''">
        and OPERATOR LIKE '%${operator}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from EMS_LOG
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from EMS_LOG
    where 1!=1 
      <if test="updatetable != null and updatetable != ''">
        or UPDATETABLE = #{updatetable}
      </if>
      <if test="code != null and code != ''">
        or CODE = #{code}
      </if>
      <if test="operatortime != null">
        or TO_CHAR(OPERATORTIME,'yyyy-MM-dd') = '#{operatortime}'
      </if>
      <if test="operator != null and operator != ''">
        or OPERATOR = #{operator}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.emslog.model.EmsLog">
    insert into EMS_LOG (ID, UPDATETABLE, CODE, 
      OPERATORTIME, OPERATOR,TYPE,PAGE)
    values (#{id,jdbcType=VARCHAR}, #{updatetable,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 
      #{operatortime,jdbcType=TIMESTAMP}, #{operator,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{page,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.emslog.model.EmsLog">
    insert into EMS_LOG
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="updatetable != null">
        UPDATETABLE,
      </if>
      <if test="code != null">
        CODE,
      </if>
      <if test="operatortime != null">
        OPERATORTIME,
      </if>
      <if test="operator != null">
        OPERATOR,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="updatetable != null">
        #{updatetable,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="operatortime != null">
        #{operatortime,jdbcType=TIMESTAMP},
      </if>
      <if test="operator != null">
        #{operator,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.emslog.model.EmsLog">
    update EMS_LOG
    set UPDATETABLE = #{updatetable,jdbcType=VARCHAR},
      CODE = #{code,jdbcType=VARCHAR},
      OPERATORTIME = #{operatortime,jdbcType=TIMESTAMP},
      OPERATOR = #{operator,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.emslog.model.EmsLog">
    update EMS_LOG
    <set>
      <if test="updatetable != null">
        UPDATETABLE = #{updatetable,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        CODE = #{code,jdbcType=VARCHAR},
      </if>
      <if test="operatortime != null">
        OPERATORTIME = #{operatortime,jdbcType=TIMESTAMP},
      </if>
      <if test="operator != null">
        OPERATOR = #{operator,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 EMS_LOG 
      (ID, 
      UPDATETABLE, CODE, OPERATORTIME, 
      OPERATOR)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.updatetable,jdbcType=VARCHAR}, #{item.code,jdbcType=VARCHAR}, #{item.operatortime,jdbcType=TIMESTAMP}, 
      #{item.operator,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update EMS_LOG
     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>
       ,UPDATETABLE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.updatetable,jdbcType=VARCHAR}
       </foreach>
       ,CODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.code,jdbcType=VARCHAR}
       </foreach>
       ,OPERATORTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.operatortime,jdbcType=TIMESTAMP}
       </foreach>
       ,OPERATOR=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.operator,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 EMS_LOG
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  
</mapper>