<?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.tmcdocdirectory.mapper.TMcDocdirectoryMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tmcdocdirectory.model.TMcDocdirectory">
    <id column="ITEMCODE" jdbcType="VARCHAR" property="itemcode" />
    <result column="NOTE" jdbcType="VARCHAR" property="note" />
    <result column="PARENTCODE" jdbcType="VARCHAR" property="parentcode" />
    <result column="RECORDID" jdbcType="DECIMAL" property="recordid" />
    <result column="PATH" jdbcType="VARCHAR" property="path" />
  </resultMap>

  <insert id="insert" parameterType="com.steerinfo.ems.tmcdocdirectory.model.TMcDocdirectory">
    insert into T_MC_DOCDIRECTORY (ITEMCODE, NOTE, PARENTCODE,
      RECORDID, PATH)
    values (#{itemcode,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{parentcode,jdbcType=VARCHAR},
      #{recordid,jdbcType=DECIMAL}, #{path,jdbcType=VARCHAR})
  </insert>

  <update id="update" parameterType="java.util.HashMap">
    update T_MC_DOCDIRECTORY
    <set>
      <if test="newcode != null">
        ITEMCODE = #{newcode,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        NOTE = #{note,jdbcType=VARCHAR},
      </if>
      <if test="path != null">
        PATH = #{path,jdbcType=VARCHAR},
      </if>
    </set>
    where ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </update>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select ITEMCODE, NOTE, PARENTCODE, RECORDID, PATH
    from T_MC_DOCDIRECTORY
    where ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_MC_DOCDIRECTORY
    where ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </delete>

  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_MC_DOCDIRECTORY
    where ITEMCODE in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>

  <select id="getTree" resultMap="BaseResultMap">
    select ITEMCODE, NOTE, PARENTCODE, PATH from T_MC_DOCDIRECTORY
  </select>

  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ITEMCODE, NOTE, PARENTCODE, RECORDID, PATH
    from T_MC_DOCDIRECTORY
    <where>
      <if test="path != null and path != ''">
        and PATH = #{path}
      </if>
    </where>
  </select>
  <!--
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tmcdocdirectory.model.TMcDocdirectory">
    update T_MC_DOCDIRECTORY
    <set>
      <if test="note != null">
        NOTE = #{note,jdbcType=VARCHAR},
      </if>
      <if test="recordid != null">
        RECORDID = #{recordid,jdbcType=DECIMAL},
      </if>
      <if test="path != null">
        PATH = #{path,jdbcType=VARCHAR},
      </if>
    </set>
    where ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </update>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_MC_DOCDIRECTORY
    where 1!=1 
      <if test="note != null and note != ''">
        and NOTE = #{note}
      </if>
      <if test="parentcode != null and parentcode != ''">
        and PARENTCODE = #{parentcode}
      </if>
      <if test="recordid != null">
        and RECORDID = #{recordid}
      </if>
      <if test="path != null and path != ''">
        and PATH = #{path}
      </if>
  </delete>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tmcdocdirectory.model.TMcDocdirectory">
    insert into T_MC_DOCDIRECTORY
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="itemcode != null">
        ITEMCODE,
      </if>
      <if test="note != null">
        NOTE,
      </if>
      <if test="parentcode != null">
        PARENTCODE,
      </if>
      <if test="recordid != null">
        RECORDID,
      </if>
      <if test="path != null">
        PATH,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="itemcode != null">
        #{itemcode,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        #{note,jdbcType=VARCHAR},
      </if>
      <if test="parentcode != null">
        #{parentcode,jdbcType=VARCHAR},
      </if>
      <if test="recordid != null">
        #{recordid,jdbcType=DECIMAL},
      </if>
      <if test="path != null">
        #{path,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tmcdocdirectory.model.TMcDocdirectory">
    update T_MC_DOCDIRECTORY
    set NOTE = #{note,jdbcType=VARCHAR},
      PARENTCODE = #{parentcode,jdbcType=VARCHAR},
      RECORDID = #{recordid,jdbcType=DECIMAL},
      PATH = #{path,jdbcType=VARCHAR}
    where ITEMCODE = #{itemcode,jdbcType=VARCHAR}
  </update>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ITEMCODE, NOTE, PARENTCODE, RECORDID, PATH
    from T_MC_DOCDIRECTORY
    <where> 
      <if test="note != null and note != ''">
        and NOTE LIKE '%${note}%'
      </if>
      <if test="parentcode != null and parentcode != ''">
        and PARENTCODE LIKE '%${parentcode}%'
      </if>
      <if test="recordid != null">
        and RECORDID = #{recordid}
      </if>
      <if test="path != null and path != ''">
        and PATH LIKE '%${path}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_MC_DOCDIRECTORY 
      (ITEMCODE, 
      NOTE, PARENTCODE, RECORDID,
      PATH)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.itemcode,jdbcType=VARCHAR}, 
      #{item.note,jdbcType=VARCHAR}, #{item.parentcode,jdbcType=VARCHAR}, #{item.recordid,jdbcType=DECIMAL},
      #{item.path,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_MC_DOCDIRECTORY
     set
       ITEMCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMCODE" close="end">
          when #{item.itemcode,jdbcType=VARCHAR} then #{item.itemcode,jdbcType=VARCHAR}
       </foreach>
       ,NOTE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMCODE" close="end">
          when #{item.itemcode,jdbcType=VARCHAR} then #{item.note,jdbcType=VARCHAR}
       </foreach>
       ,PARENTCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMCODE" close="end">
          when #{item.itemcode,jdbcType=VARCHAR} then #{item.parentcode,jdbcType=VARCHAR}
       </foreach>
       ,RECORDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMCODE" close="end">
          when #{item.itemcode,jdbcType=VARCHAR} then #{item.recordid,jdbcType=DECIMAL}
       </foreach>
       ,PATH=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMCODE" close="end">
          when #{item.itemcode,jdbcType=VARCHAR} then #{item.path,jdbcType=VARCHAR}
       </foreach>
     where ITEMCODE in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.itemcode,jdbcType=VARCHAR}
     </foreach> 
  </update>
  -->
</mapper>