<?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.load.mapper.LoadTestApiMapper">
  <resultMap id="BaseResultMap" type="io.metersphere.load.domain.LoadTestApi">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="api_id" jdbcType="VARCHAR" property="apiId" />
    <result column="load_test_id" jdbcType="VARCHAR" property="loadTestId" />
    <result column="env_id" jdbcType="VARCHAR" property="envId" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="api_version" jdbcType="INTEGER" property="apiVersion" />
  </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">
    id, api_id, load_test_id, env_id, `type`, api_version
  </sql>
  <select id="selectByExample" parameterType="io.metersphere.load.domain.LoadTestApiExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from load_test_api
    <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="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from load_test_api
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from load_test_api
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="io.metersphere.load.domain.LoadTestApiExample">
    delete from load_test_api
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="io.metersphere.load.domain.LoadTestApi">
    insert into load_test_api (id, api_id, load_test_id, 
      env_id, `type`, api_version
      )
    values (#{id,jdbcType=VARCHAR}, #{apiId,jdbcType=VARCHAR}, #{loadTestId,jdbcType=VARCHAR}, 
      #{envId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{apiVersion,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="io.metersphere.load.domain.LoadTestApi">
    insert into load_test_api
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="apiId != null">
        api_id,
      </if>
      <if test="loadTestId != null">
        load_test_id,
      </if>
      <if test="envId != null">
        env_id,
      </if>
      <if test="type != null">
        `type`,
      </if>
      <if test="apiVersion != null">
        api_version,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="apiId != null">
        #{apiId,jdbcType=VARCHAR},
      </if>
      <if test="loadTestId != null">
        #{loadTestId,jdbcType=VARCHAR},
      </if>
      <if test="envId != null">
        #{envId,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="apiVersion != null">
        #{apiVersion,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="io.metersphere.load.domain.LoadTestApiExample" resultType="java.lang.Long">
    select count(*) from load_test_api
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update load_test_api
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.apiId != null">
        api_id = #{record.apiId,jdbcType=VARCHAR},
      </if>
      <if test="record.loadTestId != null">
        load_test_id = #{record.loadTestId,jdbcType=VARCHAR},
      </if>
      <if test="record.envId != null">
        env_id = #{record.envId,jdbcType=VARCHAR},
      </if>
      <if test="record.type != null">
        `type` = #{record.type,jdbcType=VARCHAR},
      </if>
      <if test="record.apiVersion != null">
        api_version = #{record.apiVersion,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update load_test_api
    set id = #{record.id,jdbcType=VARCHAR},
      api_id = #{record.apiId,jdbcType=VARCHAR},
      load_test_id = #{record.loadTestId,jdbcType=VARCHAR},
      env_id = #{record.envId,jdbcType=VARCHAR},
      `type` = #{record.type,jdbcType=VARCHAR},
      api_version = #{record.apiVersion,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="io.metersphere.load.domain.LoadTestApi">
    update load_test_api
    <set>
      <if test="apiId != null">
        api_id = #{apiId,jdbcType=VARCHAR},
      </if>
      <if test="loadTestId != null">
        load_test_id = #{loadTestId,jdbcType=VARCHAR},
      </if>
      <if test="envId != null">
        env_id = #{envId,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        `type` = #{type,jdbcType=VARCHAR},
      </if>
      <if test="apiVersion != null">
        api_version = #{apiVersion,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="io.metersphere.load.domain.LoadTestApi">
    update load_test_api
    set api_id = #{apiId,jdbcType=VARCHAR},
      load_test_id = #{loadTestId,jdbcType=VARCHAR},
      env_id = #{envId,jdbcType=VARCHAR},
      `type` = #{type,jdbcType=VARCHAR},
      api_version = #{apiVersion,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
</mapper>