<?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.trmunit.mapper.TRmUnitMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmunit.model.TRmUnit">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="NAME" jdbcType="VARCHAR" property="name" />
    <result column="ENAME" jdbcType="VARCHAR" property="ename" />
    <result column="QNAME" jdbcType="VARCHAR" property="qname" />
    <result column="ISSTD" jdbcType="VARCHAR" property="isstd" />
    <result column="STDID" jdbcType="VARCHAR" property="stdid" />
    <result column="STDEXP" jdbcType="VARCHAR" property="stdexp" />
    <result column="CREATEMAN" jdbcType="VARCHAR" property="createman" />
    <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
    <result column="UPDATEMAN" jdbcType="VARCHAR" property="updateman"/>
    <result column="UPDATETIME" jdbcType="TIMESTAMP" property="updatetime"/>
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_UNIT
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_UNIT
    where 1=1
      <if test="name != null and name != ''">
        and NAME = #{name}
      </if>
      <if test="ename != null and ename != ''">
        and ENAME = #{ename}
      </if>
      <if test="qname != null and qname != ''">
        and QNAME = #{qname}
      </if>
      <if test="isstd != null and isstd != ''">
        and ISSTD = #{isstd}
      </if>
      <if test="stdid != null and stdid != ''">
        and STDID = #{stdid}
      </if>
      <if test="stdexp != null and stdexp != ''">
        and STDEXP = #{stdexp}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmunit.model.TRmUnit">
    insert into T_RM_UNIT (ID, NAME, ENAME, QNAME, ISSTD, STDID,
      STDEXP, CREATEMAN, CREATETIME)
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{ename,jdbcType=VARCHAR}, 
      #{qname,jdbcType=VARCHAR}, #{isstd,jdbcType=VARCHAR}, #{stdid,jdbcType=VARCHAR}, 
      #{stdexp,jdbcType=VARCHAR}, #{createman,jdbcType=VARCHAR}, SYSDATE)
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmunit.model.TRmUnit">
    insert into T_RM_UNIT
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="name != null">
        NAME,
      </if>
      <if test="ename != null">
        ENAME,
      </if>
      <if test="qname != null">
        QNAME,
      </if>
      <if test="isstd != null">
        ISSTD,
      </if>
      <if test="stdid != null">
        STDID,
      </if>
      <if test="stdexp != null">
        STDEXP,
      </if>
        CREATEMAN,
        CREATETIME
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="ename != null">
        #{ename,jdbcType=VARCHAR},
      </if>
      <if test="qname != null">
        #{qname,jdbcType=VARCHAR},
      </if>
      <if test="isstd != null">
        #{isstd,jdbcType=VARCHAR},
      </if>
      <if test="stdid != null">
        #{stdid,jdbcType=VARCHAR},
      </if>
      <if test="stdexp != null">
        #{stdexp,jdbcType=VARCHAR},
      </if>
        #{createman,jdbcType=VARCHAR},
        SYSDATE
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmunit.model.TRmUnit">
    update T_RM_UNIT
    set NAME = #{name,jdbcType=VARCHAR},
      ENAME = #{ename,jdbcType=VARCHAR},
      QNAME = #{qname,jdbcType=VARCHAR},
      ISSTD = #{isstd,jdbcType=VARCHAR},
      STDID = #{stdid,jdbcType=VARCHAR},
      STDEXP = #{stdexp,jdbcType=VARCHAR},
      UPDATEMAN = #{updateman, jdbcType=VARCHAR},
      UPDATETIME = SYSDATE
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmunit.model.TRmUnit">
    update T_RM_UNIT
    <set>
      <if test="name != null">
        NAME = #{name,jdbcType=VARCHAR},
      </if>
      <if test="ename != null">
        ENAME = #{ename,jdbcType=VARCHAR},
      </if>
      <if test="qname != null">
        QNAME = #{qname,jdbcType=VARCHAR},
      </if>
      <if test="isstd != null">
        ISSTD = #{isstd,jdbcType=VARCHAR},
      </if>
      <if test="stdid != null">
        STDID = #{stdid,jdbcType=VARCHAR},
      </if>
      <if test="stdexp != null">
        STDEXP = #{stdexp,jdbcType=VARCHAR},
      </if>
        UPDATEMAN = #{updateman, jdbcType=VARCHAR},
        UPDATETIME = SYSDATE
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select ID, NAME, ENAME, QNAME, ISSTD, STDID, STDEXP, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_RM_UNIT
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ID, NAME, ENAME, QNAME, ISSTD, STDID, STDEXP, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_RM_UNIT
    <where>
      <if test="id != null and id != ''">
        and ID = #{id}
      </if>
      <if test="name != null and name != ''">
        and NAME = #{name}
      </if>
      <if test="ename != null and ename != ''">
        and ENAME = #{ename}
      </if>
      <if test="qname != null and qname != ''">
        and QNAME = #{qname}
      </if>
      <if test="isstd != null and isstd != ''">
        and ISSTD = #{isstd}
      </if>
      <if test="stdid != null and stdid != ''">
        and STDID = #{stdid}
      </if>
      <if test="stdexp != null and stdexp != ''">
        and STDEXP = #{stdexp}
      </if>
    </where>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ID, NAME, ENAME, QNAME, ISSTD, STDID, STDEXP, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_RM_UNIT
    <where>
      <if test="id != null and id != ''">
        and ID LIKE '%${id}%'
      </if>
      <if test="name != null and name != ''">
        and NAME LIKE '%${name}%'
      </if>
      <if test="ename != null and ename != ''">
        and ENAME LIKE '%${ename}%'
      </if>
      <if test="qname != null and qname != ''">
        and QNAME LIKE '%${qname}%'
      </if>
      <if test="isstd != null and isstd != ''">
        and ISSTD = #{isstd}
      </if>
      <if test="stdid != null and stdid != ''">
        and STDID LIKE '%${stdid}%'
      </if>
      <if test="stdexp != null and stdexp != ''">
        and STDEXP LIKE '%${stdexp}%'
      </if>
    </where>
    order by id
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_UNIT 
      (ID, 
      NAME, ENAME, QNAME, 
      ISSTD, STDID, STDEXP, CREATEMAN, CREATETIME
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.name,jdbcType=VARCHAR}, #{item.ename,jdbcType=VARCHAR}, #{item.qname,jdbcType=VARCHAR}, 
      #{item.isstd,jdbcType=VARCHAR}, #{item.stdid,jdbcType=VARCHAR}, #{item.stdexp,jdbcType=VARCHAR},
      #{item.createman,jdbcType=VARCHAR}, SYSDATE
       from dual  
   </foreach> )


  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_UNIT
     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>
       ,ENAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.ename,jdbcType=VARCHAR}
       </foreach>
       ,QNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.qname,jdbcType=VARCHAR}
       </foreach>
       ,ISSTD=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.isstd,jdbcType=VARCHAR}
       </foreach>
       ,STDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.stdid,jdbcType=VARCHAR}
       </foreach>
       ,STDEXP=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.stdexp,jdbcType=VARCHAR}
       </foreach>
        ,UPDATEMAN=
        <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
            when #{item.id,jdbcType=VARCHAR} then #{item.updateman,jdbcType=VARCHAR}
        </foreach>
        ,UPDATETIME=
        <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
            when #{item.id,jdbcType=VARCHAR} then SYSDATE
        </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_UNIT
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>

    <!--查询下拉框 Id And Name-->
    <select id="getIdAndName" parameterType="java.util.HashMap" resultType="com.steerinfo.ems.trmunit.model.TRmUnit">
        SELECT ID,NAME FROM T_RM_UNIT
      <if test="isstd != null and isstd != ''">
        and ISSTD = #{isstd}
      </if>
        order by NAME
    </select>
    <!--查询下拉框 Id And Name-->
    <select id="getMaxId" resultType="java.lang.String">
        SELECT MAX(ID) FROM T_RM_UNIT
    </select>
</mapper>