<?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.bonus.sgzb.app.mapper.BmFlowMapper">
  <resultMap id="BaseResultMap" type="com.bonus.sgzb.base.api.domain.BmFlow">
    <!--@mbg.generated-->
    <!--@Table bm_flow-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="p_id" jdbcType="INTEGER" property="pId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="tag" jdbcType="VARCHAR" property="tag" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="task_type" jdbcType="VARCHAR" property="taskType" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, p_id, `name`, tag, `status`, task_type
  </sql>
  
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from bm_flow
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectAll" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from bm_flow
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from bm_flow
    where id = #{id,jdbcType=INTEGER}
  </delete>
  
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow (p_id, `name`, tag, 
      `status`, task_type)
    values (#{pId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{tag,jdbcType=VARCHAR}, 
      #{status,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR})
  </insert>
  
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="pId != null">
        p_id,
      </if>
      <if test="name != null and name != ''">
        `name`,
      </if>
      <if test="tag != null and tag != ''">
        tag,
      </if>
      <if test="status != null and status != ''">
        `status`,
      </if>
      <if test="taskType != null and taskType != ''">
        task_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="pId != null">
        #{pId,jdbcType=INTEGER},
      </if>
      <if test="name != null and name != ''">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="tag != null and tag != ''">
        #{tag,jdbcType=VARCHAR},
      </if>
      <if test="status != null and status != ''">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="taskType != null and taskType != ''">
        #{taskType,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  
  <update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.base.api.domain.BmFlow">
    <!--@mbg.generated-->
    update bm_flow
    <set>
      <if test="pId != null">
        p_id = #{pId,jdbcType=INTEGER},
      </if>
      <if test="name != null and name != ''">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="tag != null and tag != ''">
        tag = #{tag,jdbcType=VARCHAR},
      </if>
      <if test="status != null and status != ''">
        `status` = #{status,jdbcType=VARCHAR},
      </if>
      <if test="taskType != null and taskType != ''">
        task_type = #{taskType,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.base.api.domain.BmFlow">
    <!--@mbg.generated-->
    update bm_flow
    set p_id = #{pId,jdbcType=INTEGER},
      `name` = #{name,jdbcType=VARCHAR},
      tag = #{tag,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=VARCHAR},
      task_type = #{taskType,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update bm_flow
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="p_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.pId,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="`name` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.name,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="tag = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.tag,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="`status` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="task_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.taskType,jdbcType=VARCHAR}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>
  
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update bm_flow
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="p_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.pId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.pId,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="`name` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.name != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.name,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="tag = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.tag != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.tag,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="`status` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.status != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="task_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.taskType != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.taskType,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>
  
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow
    (p_id, `name`, tag, `status`, task_type)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.pId,jdbcType=INTEGER}, #{item.name,jdbcType=VARCHAR}, #{item.tag,jdbcType=VARCHAR}, 
        #{item.status,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR})
    </foreach>
  </insert>
  
  <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      p_id,
      `name`,
      tag,
      `status`,
      task_type,
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      #{pId,jdbcType=INTEGER},
      #{name,jdbcType=VARCHAR},
      #{tag,jdbcType=VARCHAR},
      #{status,jdbcType=VARCHAR},
      #{taskType,jdbcType=VARCHAR},
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      p_id = #{pId,jdbcType=INTEGER},
      `name` = #{name,jdbcType=VARCHAR},
      tag = #{tag,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=VARCHAR},
      task_type = #{taskType,jdbcType=VARCHAR},
    </trim>
  </insert>
  
  <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="pId != null">
        p_id,
      </if>
      <if test="name != null and name != ''">
        `name`,
      </if>
      <if test="tag != null and tag != ''">
        tag,
      </if>
      <if test="status != null and status != ''">
        `status`,
      </if>
      <if test="taskType != null and taskType != ''">
        task_type,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="pId != null">
        #{pId,jdbcType=INTEGER},
      </if>
      <if test="name != null and name != ''">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="tag != null and tag != ''">
        #{tag,jdbcType=VARCHAR},
      </if>
      <if test="status != null and status != ''">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="taskType != null and taskType != ''">
        #{taskType,jdbcType=VARCHAR},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      <if test="pId != null">
        p_id = #{pId,jdbcType=INTEGER},
      </if>
      <if test="name != null and name != ''">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="tag != null and tag != ''">
        tag = #{tag,jdbcType=VARCHAR},
      </if>
      <if test="status != null and status != ''">
        `status` = #{status,jdbcType=VARCHAR},
      </if>
      <if test="taskType != null and taskType != ''">
        task_type = #{taskType,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>


</mapper>