<?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.BmFlowRecordMapper">
  <resultMap id="BaseResultMap" type="com.bonus.sgzb.base.api.domain.BmFlowRecord">
    <!--@mbg.generated-->
    <!--@Table bm_flow_record-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="task_id" jdbcType="INTEGER" property="taskId" />
    <result column="flow_id" jdbcType="INTEGER" property="flowId" />
    <result column="pre_flow_id" jdbcType="INTEGER" property="preFlowId" />
    <result column="next_flow_id" jdbcType="INTEGER" property="nextFlowId" />
    <result column="creator" jdbcType="VARCHAR" property="creator" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, task_id, flow_id, pre_flow_id, next_flow_id, creator, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from bm_flow_record
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from bm_flow_record
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow_record (task_id, flow_id, pre_flow_id, 
      next_flow_id, creator, create_time
      )
    values (#{taskId,jdbcType=INTEGER}, #{flowId,jdbcType=INTEGER}, #{preFlowId,jdbcType=INTEGER}, 
      #{nextFlowId,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>

  <insert id="insertSelective" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord">
    insert into bm_flow_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="taskId != null">
        task_id,
      </if>
      <if test="flowId != null">
        flow_id,
      </if>
      <if test="preFlowId != null">
        pre_flow_id,
      </if>
      <if test="nextFlowId != null">
        next_flow_id,
      </if>
      <if test="creator != null and creator != ''">
        creator,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="taskId != null">
        #{taskId,jdbcType=INTEGER},
      </if>
      <if test="flowId != null">
        #{flowId,jdbcType=INTEGER},
      </if>
      <if test="preFlowId != null">
        #{preFlowId,jdbcType=INTEGER},
      </if>
      <if test="nextFlowId != null">
        #{nextFlowId,jdbcType=INTEGER},
      </if>
      <if test="creator != null and creator != ''">
        #{creator,jdbcType=VARCHAR}
      </if>
    </trim>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord">
    <!--@mbg.generated-->
    update bm_flow_record
    <set>
      <if test="taskId != null">
        task_id = #{taskId,jdbcType=INTEGER},
      </if>
      <if test="flowId != null">
        flow_id = #{flowId,jdbcType=INTEGER},
      </if>
      <if test="preFlowId != null">
        pre_flow_id = #{preFlowId,jdbcType=INTEGER},
      </if>
      <if test="nextFlowId != null">
        next_flow_id = #{nextFlowId,jdbcType=INTEGER},
      </if>
      <if test="creator != null and creator != ''">
        creator = #{creator,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord">
    <!--@mbg.generated-->
    update bm_flow_record
    set task_id = #{taskId,jdbcType=INTEGER},
      flow_id = #{flowId,jdbcType=INTEGER},
      pre_flow_id = #{preFlowId,jdbcType=INTEGER},
      next_flow_id = #{nextFlowId,jdbcType=INTEGER},
      creator = #{creator,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update bm_flow_record
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="task_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.taskId,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="flow_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.flowId,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="pre_flow_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.preFlowId,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="next_flow_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.nextFlowId,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="creator = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.creator,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
        </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_record
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="task_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.taskId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.taskId,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="flow_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.flowId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.flowId,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="pre_flow_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.preFlowId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.preFlowId,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="next_flow_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.nextFlowId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.nextFlowId,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="creator = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.creator != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.creator,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
          </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_record
    (task_id, flow_id, pre_flow_id, next_flow_id, creator, create_time)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.taskId,jdbcType=INTEGER}, #{item.flowId,jdbcType=INTEGER}, #{item.preFlowId,jdbcType=INTEGER}, 
        #{item.nextFlowId,jdbcType=INTEGER}, #{item.creator,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}
        )
    </foreach>
  </insert>
  <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      task_id,
      flow_id,
      pre_flow_id,
      next_flow_id,
      creator,
      create_time,
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      #{taskId,jdbcType=INTEGER},
      #{flowId,jdbcType=INTEGER},
      #{preFlowId,jdbcType=INTEGER},
      #{nextFlowId,jdbcType=INTEGER},
      #{creator,jdbcType=VARCHAR},
      #{createTime,jdbcType=TIMESTAMP},
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      task_id = #{taskId,jdbcType=INTEGER},
      flow_id = #{flowId,jdbcType=INTEGER},
      pre_flow_id = #{preFlowId,jdbcType=INTEGER},
      next_flow_id = #{nextFlowId,jdbcType=INTEGER},
      creator = #{creator,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
    </trim>
  </insert>
  <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_flow_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="taskId != null">
        task_id,
      </if>
      <if test="flowId != null">
        flow_id,
      </if>
      <if test="preFlowId != null">
        pre_flow_id,
      </if>
      <if test="nextFlowId != null">
        next_flow_id,
      </if>
      <if test="creator != null and creator != ''">
        creator,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="taskId != null">
        #{taskId,jdbcType=INTEGER},
      </if>
      <if test="flowId != null">
        #{flowId,jdbcType=INTEGER},
      </if>
      <if test="preFlowId != null">
        #{preFlowId,jdbcType=INTEGER},
      </if>
      <if test="nextFlowId != null">
        #{nextFlowId,jdbcType=INTEGER},
      </if>
      <if test="creator != null and creator != ''">
        #{creator,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      <if test="taskId != null">
        task_id = #{taskId,jdbcType=INTEGER},
      </if>
      <if test="flowId != null">
        flow_id = #{flowId,jdbcType=INTEGER},
      </if>
      <if test="preFlowId != null">
        pre_flow_id = #{preFlowId,jdbcType=INTEGER},
      </if>
      <if test="nextFlowId != null">
        next_flow_id = #{nextFlowId,jdbcType=INTEGER},
      </if>
      <if test="creator != null and creator != ''">
        creator = #{creator,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
</mapper>