<?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.tprocessinfor.mapper.TProcessinforMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tprocessinfor.model.TProcessinfor">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="NAME" jdbcType="VARCHAR" property="name" />
    <result column="STATUS" jdbcType="VARCHAR" property="status" />
    <result column="PARENTID" jdbcType="VARCHAR" property="parentid" />
    <result column="NODE" jdbcType="VARCHAR" property="node" />
    <result column="SEQNO" jdbcType="DECIMAL" property="seqno" />
  </resultMap>
  <sql id="columns">
    ID, NAME, STATUS, PARENTID, NODE, SEQNO
  </sql>
  <sql id="columns_alias">
    t.ID, t.NAME, t.STATUS, t.PARENTID, t.NODE, t.SEQNO
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_PROCESSINFOR
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_PROCESSINFOR t
  </sql>
  <sql id="where">
    <where> 
      <if test="id != null and id != ''">
        and ID = #{id}
      </if>
      <if test="name != null and name != ''">
        and NAME = #{name}
      </if>
      <if test="status != null and status != ''">
        and STATUS = #{status}
      </if>
      <if test="parentid != null and parentid != ''">
        and PARENTID = #{parentid}
      </if>
      <if test="node != null and node != ''">
        and NODE = #{node}
      </if>
      <if test="seqno != null">
        and SEQNO = #{seqno}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <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="status != null and status != ''">
        and STATUS LIKE '%${status}%'
      </if>
      <if test="parentid != null and parentid != ''">
        and PARENTID LIKE '%${parentid}%'
      </if>
      <if test="node != null and node != ''">
        and NODE LIKE '%${node}%'
      </if>
      <if test="seqno != null">
        and SEQNO = #{seqno}
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_PROCESSINFOR
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_PROCESSINFOR
    where 1!=1 
      <if test="name != null and name != ''">
        or NAME = #{name}
      </if>
      <if test="status != null and status != ''">
        or STATUS = #{status}
      </if>
      <if test="parentid != null and parentid != ''">
        or PARENTID = #{parentid}
      </if>
      <if test="node != null and node != ''">
        or NODE = #{node}
      </if>
      <if test="seqno != null">
        or SEQNO = #{seqno}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tprocessinfor.model.TProcessinfor">
    insert into T_PROCESSINFOR (ID, NAME, STATUS, 
      PARENTID, NODE, SEQNO
      )
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, 
      #{parentid,jdbcType=VARCHAR}, #{node,jdbcType=VARCHAR}, #{seqno,jdbcType=DECIMAL}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tprocessinfor.model.TProcessinfor">
    insert into T_PROCESSINFOR
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="name != null">
        NAME,
      </if>
      <if test="status != null">
        STATUS,
      </if>
      <if test="parentid != null">
        PARENTID,
      </if>
      <if test="node != null">
        NODE,
      </if>
      <if test="seqno != null">
        SEQNO,
      </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="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="parentid != null">
        #{parentid,jdbcType=VARCHAR},
      </if>
      <if test="node != null">
        #{node,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        #{seqno,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tprocessinfor.model.TProcessinfor">
    update T_PROCESSINFOR
    set NAME = #{name,jdbcType=VARCHAR},
      STATUS = #{status,jdbcType=VARCHAR},
      PARENTID = #{parentid,jdbcType=VARCHAR},
      NODE = #{node,jdbcType=VARCHAR},
      SEQNO = #{seqno,jdbcType=DECIMAL}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tprocessinfor.model.TProcessinfor">
    update T_PROCESSINFOR
    <set>
      <if test="name != null">
        NAME = #{name,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        STATUS = #{status,jdbcType=VARCHAR},
      </if>
      <if test="parentid != null">
        PARENTID = #{parentid,jdbcType=VARCHAR},
      </if>
      <if test="node != null">
        NODE = #{node,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        SEQNO = #{seqno,jdbcType=DECIMAL},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ID = #{id,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_PROCESSINFOR 
      (ID, 
      NAME, STATUS, PARENTID, 
      NODE, SEQNO)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.name,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, #{item.parentid,jdbcType=VARCHAR}, 
      #{item.node,jdbcType=VARCHAR}, #{item.seqno,jdbcType=DECIMAL} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_PROCESSINFOR
     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>
       ,STATUS=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.status,jdbcType=VARCHAR}
       </foreach>
       ,PARENTID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.parentid,jdbcType=VARCHAR}
       </foreach>
       ,NODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.node,jdbcType=VARCHAR}
       </foreach>
       ,SEQNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.seqno,jdbcType=DECIMAL}
       </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_PROCESSINFOR
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="getTree" resultMap="BaseResultMap">
    select ID, NAME, PARENTID, NODE from T_PROCESSINFOR
    WHERE 1=1
    order by SEQNO
  </select>

  <select id="getParent" resultMap="BaseResultMap">
    select ID, NAME, NODE from T_PROCESSINFOR
    where ID in (select distinct PARENTID from T_PROCESSINFOR)
    order by SEQNO
  </select>
  <select id="getMaxSeqNo" resultType="java.lang.Integer">
    SELECT MAX(SEQNO) FROM T_PROCESSINFOR
  </select>
  <!--查询下拉框的值-->
  <select id="getIdAndName" parameterType="java.util.HashMap" resultType="com.steerinfo.ems.tprocessinfor.model.TProcessinfor">
    SELECT ID,NAME,NODE FROM T_PROCESSINFOR
    where 1=1
    <if test="id != null and id != ''">
      and id in (${id})
    </if>
    ORDER BY NAME
  </select>

  <select id="getMenus" resultMap="BaseResultMap">
    select ID, NAME, NODE from T_PROCESSINFOR
    where NODE = #{node,jdbcType=VARCHAR} and NAME LIKE '%${name}%'
    order by SEQNO
  </select>
</mapper>