<?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="io.metersphere.plan.mapper.TestPlanConfigMapper">
  <resultMap id="BaseResultMap" type="io.metersphere.plan.domain.TestPlanConfig">
    <id column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
    <result column="automatic_status_update" jdbcType="BIT" property="automaticStatusUpdate" />
    <result column="repeat_case" jdbcType="BIT" property="repeatCase" />
    <result column="pass_threshold" jdbcType="INTEGER" property="passThreshold" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.plan.domain.TestPlanConfig">
    <result column="run_mode_config" jdbcType="LONGVARCHAR" property="runModeConfig" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    test_plan_id, automatic_status_update, repeat_case, pass_threshold
  </sql>
  <sql id="Blob_Column_List">
    run_mode_config
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="io.metersphere.plan.domain.TestPlanConfigExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from test_plan_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="io.metersphere.plan.domain.TestPlanConfigExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from test_plan_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from test_plan_config
    where test_plan_id = #{testPlanId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from test_plan_config
    where test_plan_id = #{testPlanId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="io.metersphere.plan.domain.TestPlanConfigExample">
    delete from test_plan_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="io.metersphere.plan.domain.TestPlanConfig">
    insert into test_plan_config (test_plan_id, automatic_status_update, repeat_case, 
      pass_threshold, run_mode_config)
    values (#{testPlanId,jdbcType=VARCHAR}, #{automaticStatusUpdate,jdbcType=BIT}, #{repeatCase,jdbcType=BIT}, 
      #{passThreshold,jdbcType=INTEGER}, #{runModeConfig,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="io.metersphere.plan.domain.TestPlanConfig">
    insert into test_plan_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="testPlanId != null">
        test_plan_id,
      </if>
      <if test="automaticStatusUpdate != null">
        automatic_status_update,
      </if>
      <if test="repeatCase != null">
        repeat_case,
      </if>
      <if test="passThreshold != null">
        pass_threshold,
      </if>
      <if test="runModeConfig != null">
        run_mode_config,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="testPlanId != null">
        #{testPlanId,jdbcType=VARCHAR},
      </if>
      <if test="automaticStatusUpdate != null">
        #{automaticStatusUpdate,jdbcType=BIT},
      </if>
      <if test="repeatCase != null">
        #{repeatCase,jdbcType=BIT},
      </if>
      <if test="passThreshold != null">
        #{passThreshold,jdbcType=INTEGER},
      </if>
      <if test="runModeConfig != null">
        #{runModeConfig,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="io.metersphere.plan.domain.TestPlanConfigExample" resultType="java.lang.Long">
    select count(*) from test_plan_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update test_plan_config
    <set>
      <if test="record.testPlanId != null">
        test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
      </if>
      <if test="record.automaticStatusUpdate != null">
        automatic_status_update = #{record.automaticStatusUpdate,jdbcType=BIT},
      </if>
      <if test="record.repeatCase != null">
        repeat_case = #{record.repeatCase,jdbcType=BIT},
      </if>
      <if test="record.passThreshold != null">
        pass_threshold = #{record.passThreshold,jdbcType=INTEGER},
      </if>
      <if test="record.runModeConfig != null">
        run_mode_config = #{record.runModeConfig,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update test_plan_config
    set test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
      automatic_status_update = #{record.automaticStatusUpdate,jdbcType=BIT},
      repeat_case = #{record.repeatCase,jdbcType=BIT},
      pass_threshold = #{record.passThreshold,jdbcType=INTEGER},
      run_mode_config = #{record.runModeConfig,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update test_plan_config
    set test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
      automatic_status_update = #{record.automaticStatusUpdate,jdbcType=BIT},
      repeat_case = #{record.repeatCase,jdbcType=BIT},
      pass_threshold = #{record.passThreshold,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="io.metersphere.plan.domain.TestPlanConfig">
    update test_plan_config
    <set>
      <if test="automaticStatusUpdate != null">
        automatic_status_update = #{automaticStatusUpdate,jdbcType=BIT},
      </if>
      <if test="repeatCase != null">
        repeat_case = #{repeatCase,jdbcType=BIT},
      </if>
      <if test="passThreshold != null">
        pass_threshold = #{passThreshold,jdbcType=INTEGER},
      </if>
      <if test="runModeConfig != null">
        run_mode_config = #{runModeConfig,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where test_plan_id = #{testPlanId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.plan.domain.TestPlanConfig">
    update test_plan_config
    set automatic_status_update = #{automaticStatusUpdate,jdbcType=BIT},
      repeat_case = #{repeatCase,jdbcType=BIT},
      pass_threshold = #{passThreshold,jdbcType=INTEGER},
      run_mode_config = #{runModeConfig,jdbcType=LONGVARCHAR}
    where test_plan_id = #{testPlanId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="io.metersphere.plan.domain.TestPlanConfig">
    update test_plan_config
    set automatic_status_update = #{automaticStatusUpdate,jdbcType=BIT},
      repeat_case = #{repeatCase,jdbcType=BIT},
      pass_threshold = #{passThreshold,jdbcType=INTEGER}
    where test_plan_id = #{testPlanId,jdbcType=VARCHAR}
  </update>
</mapper>