<?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.tcmcodeitem.mapper.TCmCodeitemMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcmcodeitem.model.TCmCodeitem">
    <id column="TYPECODE" jdbcType="VARCHAR" property="typecode" />
    <id column="ITEMCODE" jdbcType="VARCHAR" property="itemcode" />
    <result column="ITEMNAME" jdbcType="VARCHAR" property="itemname" />
    <result column="ITEMENAME" jdbcType="VARCHAR" property="itemename" />
    <result column="ITEMDESC" jdbcType="VARCHAR" property="itemdesc" />
    <result column="ITEMCODE_1" jdbcType="VARCHAR" property="itemcode1" />
    <result column="ITEMDESC_1" jdbcType="VARCHAR" property="itemdesc1" />
    <result column="REC_CREATOR" jdbcType="VARCHAR" property="recCreator" />
    <result column="REC_CREATETIME" jdbcType="VARCHAR" property="recCreatetime" />
    <result column="CLASSIFY1" jdbcType="VARCHAR" property="classify1" />
    <result column="CLASSIFY2" jdbcType="VARCHAR" property="classify2" />
    <result column="CLASSIFY3" jdbcType="VARCHAR" property="classify3" />
    <result column="CLASSIFY4" jdbcType="VARCHAR" property="classify4" />
    <result column="CLASSIFY5" jdbcType="VARCHAR" property="classify5" />
    <result column="BCODE" jdbcType="VARCHAR" property="bcode" />
    <result column="BDESC1" jdbcType="VARCHAR" property="bdesc1" />
    <result column="BDESC2" jdbcType="VARCHAR" property="bdesc2" />
    <result column="SEQNO" jdbcType="DECIMAL" property="seqno" />
  </resultMap>

    <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
        select TYPECODE, ITEMCODE, ITEMNAME from T_CM_CODEITEM where TYPECODE = #{typecode}
        order by ITEMNAME
    </select>

  <!--
  <delete id="deleteByPrimaryKey" parameterType="map">
    delete from T_CM_CODEITEM
    where TYPECODE = #{typecode,jdbcType=VARCHAR}
      and ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_CODEITEM
    where 1!=1 
      <if test="itemcode != null and itemcode != ''">
        and ITEMCODE = #{itemcode}
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME = #{itemname}
      </if>
      <if test="itemename != null and itemename != ''">
        and ITEMENAME = #{itemename}
      </if>
      <if test="itemdesc != null and itemdesc != ''">
        and ITEMDESC = #{itemdesc}
      </if>
      <if test="itemcode1 != null and itemcode1 != ''">
        and ITEMCODE_1 = #{itemcode1}
      </if>
      <if test="itemdesc1 != null and itemdesc1 != ''">
        and ITEMDESC_1 = #{itemdesc1}
      </if>
      <if test="recCreator != null and recCreator != ''">
        and REC_CREATOR = #{recCreator}
      </if>
      <if test="recCreatetime != null and recCreatetime != ''">
        and REC_CREATETIME = #{recCreatetime}
      </if>
      <if test="classify1 != null and classify1 != ''">
        and CLASSIFY1 = #{classify1}
      </if>
      <if test="classify2 != null and classify2 != ''">
        and CLASSIFY2 = #{classify2}
      </if>
      <if test="classify3 != null and classify3 != ''">
        and CLASSIFY3 = #{classify3}
      </if>
      <if test="classify4 != null and classify4 != ''">
        and CLASSIFY4 = #{classify4}
      </if>
      <if test="classify5 != null and classify5 != ''">
        and CLASSIFY5 = #{classify5}
      </if>
      <if test="bcode != null and bcode != ''">
        and BCODE = #{bcode}
      </if>
      <if test="bdesc1 != null and bdesc1 != ''">
        and BDESC1 = #{bdesc1}
      </if>
      <if test="bdesc2 != null and bdesc2 != ''">
        and BDESC2 = #{bdesc2}
      </if>
      <if test="seqno != null">
        and SEQNO = #{seqno}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tcmcodeitem.model.TCmCodeitem">
    insert into T_CM_CODEITEM (TYPECODE, ITEMCODE, ITEMNAME, 
      ITEMENAME, ITEMDESC, ITEMCODE_1, 
      ITEMDESC_1, REC_CREATOR, REC_CREATETIME, 
      CLASSIFY1, CLASSIFY2, CLASSIFY3, 
      CLASSIFY4, CLASSIFY5, BCODE, 
      BDESC1, BDESC2, SEQNO
      )
    values (#{typecode,jdbcType=VARCHAR}, #{itemcode,jdbcType=VARCHAR}, #{itemname,jdbcType=VARCHAR}, 
      #{itemename,jdbcType=VARCHAR}, #{itemdesc,jdbcType=VARCHAR}, #{itemcode1,jdbcType=VARCHAR}, 
      #{itemdesc1,jdbcType=VARCHAR}, #{recCreator,jdbcType=VARCHAR}, #{recCreatetime,jdbcType=VARCHAR}, 
      #{classify1,jdbcType=VARCHAR}, #{classify2,jdbcType=VARCHAR}, #{classify3,jdbcType=VARCHAR}, 
      #{classify4,jdbcType=VARCHAR}, #{classify5,jdbcType=VARCHAR}, #{bcode,jdbcType=VARCHAR}, 
      #{bdesc1,jdbcType=VARCHAR}, #{bdesc2,jdbcType=VARCHAR}, #{seqno,jdbcType=DECIMAL}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcmcodeitem.model.TCmCodeitem">
    insert into T_CM_CODEITEM
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="typecode != null">
        TYPECODE,
      </if>
      <if test="itemcode != null">
        ITEMCODE,
      </if>
      <if test="itemname != null">
        ITEMNAME,
      </if>
      <if test="itemename != null">
        ITEMENAME,
      </if>
      <if test="itemdesc != null">
        ITEMDESC,
      </if>
      <if test="itemcode1 != null">
        ITEMCODE_1,
      </if>
      <if test="itemdesc1 != null">
        ITEMDESC_1,
      </if>
      <if test="recCreator != null">
        REC_CREATOR,
      </if>
      <if test="recCreatetime != null">
        REC_CREATETIME,
      </if>
      <if test="classify1 != null">
        CLASSIFY1,
      </if>
      <if test="classify2 != null">
        CLASSIFY2,
      </if>
      <if test="classify3 != null">
        CLASSIFY3,
      </if>
      <if test="classify4 != null">
        CLASSIFY4,
      </if>
      <if test="classify5 != null">
        CLASSIFY5,
      </if>
      <if test="bcode != null">
        BCODE,
      </if>
      <if test="bdesc1 != null">
        BDESC1,
      </if>
      <if test="bdesc2 != null">
        BDESC2,
      </if>
      <if test="seqno != null">
        SEQNO,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="typecode != null">
        #{typecode,jdbcType=VARCHAR},
      </if>
      <if test="itemcode != null">
        #{itemcode,jdbcType=VARCHAR},
      </if>
      <if test="itemname != null">
        #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="itemename != null">
        #{itemename,jdbcType=VARCHAR},
      </if>
      <if test="itemdesc != null">
        #{itemdesc,jdbcType=VARCHAR},
      </if>
      <if test="itemcode1 != null">
        #{itemcode1,jdbcType=VARCHAR},
      </if>
      <if test="itemdesc1 != null">
        #{itemdesc1,jdbcType=VARCHAR},
      </if>
      <if test="recCreator != null">
        #{recCreator,jdbcType=VARCHAR},
      </if>
      <if test="recCreatetime != null">
        #{recCreatetime,jdbcType=VARCHAR},
      </if>
      <if test="classify1 != null">
        #{classify1,jdbcType=VARCHAR},
      </if>
      <if test="classify2 != null">
        #{classify2,jdbcType=VARCHAR},
      </if>
      <if test="classify3 != null">
        #{classify3,jdbcType=VARCHAR},
      </if>
      <if test="classify4 != null">
        #{classify4,jdbcType=VARCHAR},
      </if>
      <if test="classify5 != null">
        #{classify5,jdbcType=VARCHAR},
      </if>
      <if test="bcode != null">
        #{bcode,jdbcType=VARCHAR},
      </if>
      <if test="bdesc1 != null">
        #{bdesc1,jdbcType=VARCHAR},
      </if>
      <if test="bdesc2 != null">
        #{bdesc2,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        #{seqno,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcmcodeitem.model.TCmCodeitem">
    update T_CM_CODEITEM
    set ITEMNAME = #{itemname,jdbcType=VARCHAR},
      ITEMENAME = #{itemename,jdbcType=VARCHAR},
      ITEMDESC = #{itemdesc,jdbcType=VARCHAR},
      ITEMCODE_1 = #{itemcode1,jdbcType=VARCHAR},
      ITEMDESC_1 = #{itemdesc1,jdbcType=VARCHAR},
      REC_CREATOR = #{recCreator,jdbcType=VARCHAR},
      REC_CREATETIME = #{recCreatetime,jdbcType=VARCHAR},
      CLASSIFY1 = #{classify1,jdbcType=VARCHAR},
      CLASSIFY2 = #{classify2,jdbcType=VARCHAR},
      CLASSIFY3 = #{classify3,jdbcType=VARCHAR},
      CLASSIFY4 = #{classify4,jdbcType=VARCHAR},
      CLASSIFY5 = #{classify5,jdbcType=VARCHAR},
      BCODE = #{bcode,jdbcType=VARCHAR},
      BDESC1 = #{bdesc1,jdbcType=VARCHAR},
      BDESC2 = #{bdesc2,jdbcType=VARCHAR},
      SEQNO = #{seqno,jdbcType=DECIMAL}
    where TYPECODE = #{typecode,jdbcType=VARCHAR}
      and ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcmcodeitem.model.TCmCodeitem">
    update T_CM_CODEITEM
    <set>
      <if test="itemname != null">
        ITEMNAME = #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="itemename != null">
        ITEMENAME = #{itemename,jdbcType=VARCHAR},
      </if>
      <if test="itemdesc != null">
        ITEMDESC = #{itemdesc,jdbcType=VARCHAR},
      </if>
      <if test="itemcode1 != null">
        ITEMCODE_1 = #{itemcode1,jdbcType=VARCHAR},
      </if>
      <if test="itemdesc1 != null">
        ITEMDESC_1 = #{itemdesc1,jdbcType=VARCHAR},
      </if>
      <if test="recCreator != null">
        REC_CREATOR = #{recCreator,jdbcType=VARCHAR},
      </if>
      <if test="recCreatetime != null">
        REC_CREATETIME = #{recCreatetime,jdbcType=VARCHAR},
      </if>
      <if test="classify1 != null">
        CLASSIFY1 = #{classify1,jdbcType=VARCHAR},
      </if>
      <if test="classify2 != null">
        CLASSIFY2 = #{classify2,jdbcType=VARCHAR},
      </if>
      <if test="classify3 != null">
        CLASSIFY3 = #{classify3,jdbcType=VARCHAR},
      </if>
      <if test="classify4 != null">
        CLASSIFY4 = #{classify4,jdbcType=VARCHAR},
      </if>
      <if test="classify5 != null">
        CLASSIFY5 = #{classify5,jdbcType=VARCHAR},
      </if>
      <if test="bcode != null">
        BCODE = #{bcode,jdbcType=VARCHAR},
      </if>
      <if test="bdesc1 != null">
        BDESC1 = #{bdesc1,jdbcType=VARCHAR},
      </if>
      <if test="bdesc2 != null">
        BDESC2 = #{bdesc2,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        SEQNO = #{seqno,jdbcType=DECIMAL},
      </if>
    </set>
    where TYPECODE = #{typecode,jdbcType=VARCHAR}
      and ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
    select TYPECODE, ITEMCODE, ITEMNAME, ITEMENAME, ITEMDESC, ITEMCODE_1, ITEMDESC_1, 
    REC_CREATOR, REC_CREATETIME, CLASSIFY1, CLASSIFY2, CLASSIFY3, CLASSIFY4, CLASSIFY5, 
    BCODE, BDESC1, BDESC2, SEQNO
    from T_CM_CODEITEM
    where TYPECODE = #{typecode,jdbcType=VARCHAR}
      and ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select TYPECODE, ITEMCODE, ITEMNAME, ITEMENAME, ITEMDESC, ITEMCODE_1, ITEMDESC_1, 
    REC_CREATOR, REC_CREATETIME, CLASSIFY1, CLASSIFY2, CLASSIFY3, CLASSIFY4, CLASSIFY5, 
    BCODE, BDESC1, BDESC2, SEQNO
    from T_CM_CODEITEM
    <where> 
      <if test="itemcode != null and itemcode != ''">
        and ITEMCODE LIKE '%${itemcode}%'
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME LIKE '%${itemname}%'
      </if>
      <if test="itemename != null and itemename != ''">
        and ITEMENAME LIKE '%${itemename}%'
      </if>
      <if test="itemdesc != null and itemdesc != ''">
        and ITEMDESC LIKE '%${itemdesc}%'
      </if>
      <if test="itemcode1 != null and itemcode1 != ''">
        and ITEMCODE_1 LIKE '%${itemcode1}%'
      </if>
      <if test="itemdesc1 != null and itemdesc1 != ''">
        and ITEMDESC_1 LIKE '%${itemdesc1}%'
      </if>
      <if test="recCreator != null and recCreator != ''">
        and REC_CREATOR LIKE '%${recCreator}%'
      </if>
      <if test="recCreatetime != null and recCreatetime != ''">
        and REC_CREATETIME LIKE '%${recCreatetime}%'
      </if>
      <if test="classify1 != null and classify1 != ''">
        and CLASSIFY1 LIKE '%${classify1}%'
      </if>
      <if test="classify2 != null and classify2 != ''">
        and CLASSIFY2 LIKE '%${classify2}%'
      </if>
      <if test="classify3 != null and classify3 != ''">
        and CLASSIFY3 LIKE '%${classify3}%'
      </if>
      <if test="classify4 != null and classify4 != ''">
        and CLASSIFY4 LIKE '%${classify4}%'
      </if>
      <if test="classify5 != null and classify5 != ''">
        and CLASSIFY5 LIKE '%${classify5}%'
      </if>
      <if test="bcode != null and bcode != ''">
        and BCODE LIKE '%${bcode}%'
      </if>
      <if test="bdesc1 != null and bdesc1 != ''">
        and BDESC1 LIKE '%${bdesc1}%'
      </if>
      <if test="bdesc2 != null and bdesc2 != ''">
        and BDESC2 LIKE '%${bdesc2}%'
      </if>
      <if test="seqno != null">
        and SEQNO = #{seqno}
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_CODEITEM 
      (TYPECODE, 
      ITEMCODE, ITEMNAME, ITEMENAME, 
      ITEMDESC, ITEMCODE_1, ITEMDESC_1, 
      REC_CREATOR, REC_CREATETIME, CLASSIFY1, 
      CLASSIFY2, CLASSIFY3, CLASSIFY4, 
      CLASSIFY5, BCODE, BDESC1, 
      BDESC2, SEQNO)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.typecode,jdbcType=VARCHAR}, 
      #{item.itemcode,jdbcType=VARCHAR}, #{item.itemname,jdbcType=VARCHAR}, #{item.itemename,jdbcType=VARCHAR}, 
      #{item.itemdesc,jdbcType=VARCHAR}, #{item.itemcode1,jdbcType=VARCHAR}, #{item.itemdesc1,jdbcType=VARCHAR}, 
      #{item.recCreator,jdbcType=VARCHAR}, #{item.recCreatetime,jdbcType=VARCHAR}, #{item.classify1,jdbcType=VARCHAR}, 
      #{item.classify2,jdbcType=VARCHAR}, #{item.classify3,jdbcType=VARCHAR}, #{item.classify4,jdbcType=VARCHAR}, 
      #{item.classify5,jdbcType=VARCHAR}, #{item.bcode,jdbcType=VARCHAR}, #{item.bdesc1,jdbcType=VARCHAR}, 
      #{item.bdesc2,jdbcType=VARCHAR}, #{item.seqno,jdbcType=DECIMAL} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_CODEITEM
     set
       TYPECODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.typecode,jdbcType=VARCHAR}
       </foreach>
       ,ITEMCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.itemcode,jdbcType=VARCHAR}
       </foreach>
       ,ITEMNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.itemname,jdbcType=VARCHAR}
       </foreach>
       ,ITEMENAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.itemename,jdbcType=VARCHAR}
       </foreach>
       ,ITEMDESC=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.itemdesc,jdbcType=VARCHAR}
       </foreach>
       ,ITEMCODE_1=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.itemcode1,jdbcType=VARCHAR}
       </foreach>
       ,ITEMDESC_1=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.itemdesc1,jdbcType=VARCHAR}
       </foreach>
       ,REC_CREATOR=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.recCreator,jdbcType=VARCHAR}
       </foreach>
       ,REC_CREATETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.recCreatetime,jdbcType=VARCHAR}
       </foreach>
       ,CLASSIFY1=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.classify1,jdbcType=VARCHAR}
       </foreach>
       ,CLASSIFY2=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.classify2,jdbcType=VARCHAR}
       </foreach>
       ,CLASSIFY3=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.classify3,jdbcType=VARCHAR}
       </foreach>
       ,CLASSIFY4=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.classify4,jdbcType=VARCHAR}
       </foreach>
       ,CLASSIFY5=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.classify5,jdbcType=VARCHAR}
       </foreach>
       ,BCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.bcode,jdbcType=VARCHAR}
       </foreach>
       ,BDESC1=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.bdesc1,jdbcType=VARCHAR}
       </foreach>
       ,BDESC2=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.bdesc2,jdbcType=VARCHAR}
       </foreach>
       ,SEQNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case TYPECODE" close="end">
          when #{item.typecode,jdbcType=VARCHAR} then #{item.seqno,jdbcType=DECIMAL}
       </foreach>
     where TYPECODE in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.typecode,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_CM_CODEITEM
    where TYPECODE in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  -->
</mapper>