<?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.trml1source.mapper.TRmL1sourceMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trml1source.model.TRmL1source">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="NAME" jdbcType="VARCHAR" property="name" />
    <result column="REMARK" jdbcType="VARCHAR" property="remark" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_L1SOURCE
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_L1SOURCE
    where 1=1
      <if test="name != null and name != ''">
        and NAME = #{name}
      </if>
      <if test="remark != null and remark != ''">
        and REMARK = #{remark}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trml1source.model.TRmL1source">
    insert into T_RM_L1SOURCE (ID, NAME, REMARK
      )
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trml1source.model.TRmL1source">
    insert into T_RM_L1SOURCE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="name != null">
        NAME,
      </if>
      <if test="remark != null">
        REMARK,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trml1source.model.TRmL1source">
    update T_RM_L1SOURCE
    set NAME = #{name,jdbcType=VARCHAR},
      REMARK = #{remark,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trml1source.model.TRmL1source">
    update T_RM_L1SOURCE
    <set>
      <if test="name != null">
        NAME = #{name,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select ID, NAME, REMARK
    from T_RM_L1SOURCE
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ID, NAME, REMARK
    from T_RM_L1SOURCE
    <where> 
      <if test="name != null and name != ''">
        and NAME = #{name}
      </if>
      <if test="remark != null and remark != ''">
        and REMARK = #{remark}
      </if>
    </where>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ID, NAME, REMARK
    from T_RM_L1SOURCE
    <where> 
      <if test="name != null and name != ''">
        and NAME LIKE '%${name}%'
      </if>
      <if test="remark != null and remark != ''">
        and REMARK LIKE '%${remark}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_L1SOURCE 
      (ID, 
      NAME, REMARK)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.name,jdbcType=VARCHAR}, #{item.remark,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_L1SOURCE
     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>
       ,NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.name,jdbcType=VARCHAR}
       </foreach>
       ,REMARK=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.remark,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_RM_L1SOURCE
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <select id="getNameAndId" resultMap="BaseResultMap">
    select ID, NAME from T_RM_L1SOURCE
  </select>
</mapper>