<?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.trmindextype.mapper.TRmIndexTypeMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmindextype.model.TRmIndexType">
    <id column="INDEXCOL" jdbcType="VARCHAR" property="indexcol" />
    <id column="INDEXID" jdbcType="VARCHAR" property="indexid" />
    <result column="INDEXNAME" jdbcType="VARCHAR" property="indexname" />
    <result column="INDEXDESC" jdbcType="VARCHAR" property="indexdesc" />
    <result column="INDEXCODE" jdbcType="DECIMAL" property="indexcode" />
  </resultMap>
  <sql id="columns">
    INDEXCOL, INDEXID, INDEXNAME, INDEXDESC, INDEXCODE
  </sql>
  <sql id="columns_alias">
    t.INDEXCOL, t.INDEXID, t.INDEXNAME, t.INDEXDESC, t.INDEXCODE
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_RM_INDEX_TYPE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_RM_INDEX_TYPE t
  </sql>
  <sql id="where">
    <where>
      <if test="indexid != null and indexid != ''">
        and INDEXID = #{indexid}
      </if>
      <if test="indexname != null and indexname != ''">
        and INDEXNAME = #{indexname}
      </if>
      <if test="indexdesc != null and indexdesc != ''">
        and INDEXDESC = #{indexdesc}
      </if>
      <if test="indexcode != null">
        and INDEXCODE = #{indexcode}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="indexid != null and indexid != ''">
        and INDEXID LIKE '%${indexid}%'
      </if>
      <if test="indexname != null and indexname != ''">
        and INDEXNAME LIKE '%${indexname}%'
      </if>
      <if test="indexdesc != null and indexdesc != ''">
        and INDEXDESC LIKE '%${indexdesc}%'
      </if>
      <if test="indexcode != null">
        and INDEXCODE = #{indexcode}
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="map">
    delete from T_RM_INDEX_TYPE
    where INDEXCOL = #{indexcol,jdbcType=VARCHAR}
      and INDEXID = #{indexid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_INDEX_TYPE
    where 1!=1
    <if test="indexid != null and indexid != ''">
      or INDEXID = #{indexid}
    </if>
    <if test="indexname != null and indexname != ''">
      or INDEXNAME = #{indexname}
    </if>
    <if test="indexdesc != null and indexdesc != ''">
      or INDEXDESC = #{indexdesc}
    </if>
    <if test="indexcode != null">
      or INDEXCODE = #{indexcode}
    </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmindextype.model.TRmIndexType">
    insert into T_RM_INDEX_TYPE (INDEXCOL, INDEXID, INDEXNAME,
      INDEXDESC, INDEXCODE)
    values (#{indexcol,jdbcType=VARCHAR}, #{indexid,jdbcType=VARCHAR}, #{indexname,jdbcType=VARCHAR},
      #{indexdesc,jdbcType=VARCHAR}, #{indexcode,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmindextype.model.TRmIndexType">
    insert into T_RM_INDEX_TYPE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="indexcol != null">
        INDEXCOL,
      </if>
      <if test="indexid != null">
        INDEXID,
      </if>
      <if test="indexname != null">
        INDEXNAME,
      </if>
      <if test="indexdesc != null">
        INDEXDESC,
      </if>
      <if test="indexcode != null">
        INDEXCODE,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="indexcol != null">
        #{indexcol,jdbcType=VARCHAR},
      </if>
      <if test="indexid != null">
        #{indexid,jdbcType=VARCHAR},
      </if>
      <if test="indexname != null">
        #{indexname,jdbcType=VARCHAR},
      </if>
      <if test="indexdesc != null">
        #{indexdesc,jdbcType=VARCHAR},
      </if>
      <if test="indexcode != null">
        #{indexcode,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmindextype.model.TRmIndexType">
    update T_RM_INDEX_TYPE
    set INDEXNAME = #{indexname,jdbcType=VARCHAR},
      INDEXDESC = #{indexdesc,jdbcType=VARCHAR},
      INDEXCODE = #{indexcode,jdbcType=DECIMAL}
    where INDEXCOL = #{indexcol,jdbcType=VARCHAR}
      and INDEXID = #{indexid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmindextype.model.TRmIndexType">
    update T_RM_INDEX_TYPE
    <set>
      <if test="indexname != null">
        INDEXNAME = #{indexname,jdbcType=VARCHAR},
      </if>
      <if test="indexdesc != null">
        INDEXDESC = #{indexdesc,jdbcType=VARCHAR},
      </if>
      <if test="indexcode != null">
        INDEXCODE = #{indexcode,jdbcType=DECIMAL},
      </if>
    </set>
    where INDEXCOL = #{indexcol,jdbcType=VARCHAR}
    and INDEXID = #{indexid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
    <include refid="select"/>
    where INDEXCOL = #{indexcol,jdbcType=VARCHAR}
    and INDEXID = #{indexid,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_RM_INDEX_TYPE
    (INDEXCOL,
    INDEXID, INDEXNAME, INDEXDESC,
    INDEXCODE)
    ( <foreach collection="list" item="item" separator="union all">
    select
    #{item.indexcol,jdbcType=VARCHAR},
    #{item.indexid,jdbcType=VARCHAR}, #{item.indexname,jdbcType=VARCHAR}, #{item.indexdesc,jdbcType=VARCHAR},
    #{item.indexcode,jdbcType=DECIMAL} from dual
  </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
    update T_RM_INDEX_TYPE
    set
    INDEXCOL=
    <foreach collection="list" item="item" index="index" separator=" " open="case INDEXCOL" close="end">
      when #{item.indexcol,jdbcType=VARCHAR} then #{item.indexcol,jdbcType=VARCHAR}
    </foreach>
    ,INDEXID=
    <foreach collection="list" item="item" index="index" separator=" " open="case INDEXCOL" close="end">
      when #{item.indexcol,jdbcType=VARCHAR} then #{item.indexid,jdbcType=VARCHAR}
    </foreach>
    ,INDEXNAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case INDEXCOL" close="end">
      when #{item.indexcol,jdbcType=VARCHAR} then #{item.indexname,jdbcType=VARCHAR}
    </foreach>
    ,INDEXDESC=
    <foreach collection="list" item="item" index="index" separator=" " open="case INDEXCOL" close="end">
      when #{item.indexcol,jdbcType=VARCHAR} then #{item.indexdesc,jdbcType=VARCHAR}
    </foreach>
    ,INDEXCODE=
    <foreach collection="list" item="item" index="index" separator=" " open="case INDEXCOL" close="end">
      when #{item.indexcol,jdbcType=VARCHAR} then #{item.indexcode,jdbcType=DECIMAL}
    </foreach>
    where INDEXCOL in
    <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
      #{item.indexcol,jdbcType=VARCHAR}
    </foreach>
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_RM_INDEX_TYPE
    where INDEXCOL in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->

    <!--查询联合主键-->
    <select id="getCombinedPrimaryKey" resultType="string">
        SELECT INDEXCOL||INDEXID FROM T_RM_INDEX_TYPE
    </select>

    <!--根据联合组件删除-->
    <delete id="deleteByCompositePrimaryKey" parameterType="com.steerinfo.ems.trmindextype.model.TRmIndexType">
          DELETE  FROM T_RM_INDEX_TYPE WHERE
          INDEXCOL = #{indexcol,jdbcType=VARCHAR}
      AND INDEXID = #{indexid,jdbcType=VARCHAR}
    </delete>

    <!--下拉框查询-->
    <select id="getIdAndName" parameterType="string" resultMap="BaseResultMap">
        SELECT INDEXID,INDEXNAME FROM T_RM_INDEX_TYPE order by INDEXCODE
        <where>
            <if test="indexcol !=null and indexcol !=''">
                INDEXCOL = #{indexcol}
            </if>
        </where>
    </select>
</mapper>