<?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.project.mapper.CustomFieldMapper">
  <resultMap id="BaseResultMap" type="io.metersphere.project.domain.CustomField">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="scene" jdbcType="VARCHAR" property="scene" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="system" jdbcType="BIT" property="system" />
    <result column="global" jdbcType="BIT" property="global" />
    <result column="create_time" jdbcType="BIGINT" property="createTime" />
    <result column="update_time" jdbcType="BIGINT" property="updateTime" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
    <result column="project_id" jdbcType="VARCHAR" property="projectId" />
    <result column="third_part" jdbcType="BIT" property="thirdPart" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.project.domain.CustomField">
    <result column="options" jdbcType="LONGVARCHAR" property="options" />
  </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, `name`, scene, `type`, remark, `system`, `global`, create_time, update_time, 
    create_user, project_id, third_part
  </sql>
  <sql id="Blob_Column_List">
    `options`
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="io.metersphere.project.domain.CustomFieldExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from custom_field
    <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.project.domain.CustomFieldExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from custom_field
    <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 custom_field
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from custom_field
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="io.metersphere.project.domain.CustomFieldExample">
    delete from custom_field
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="io.metersphere.project.domain.CustomField">
    insert into custom_field (id, `name`, scene, 
      `type`, remark, `system`, `global`, 
      create_time, update_time, create_user, 
      project_id, third_part, `options`
      )
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{scene,jdbcType=VARCHAR}, 
      #{type,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{system,jdbcType=BIT}, #{global,jdbcType=BIT}, 
      #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, 
      #{projectId,jdbcType=VARCHAR}, #{thirdPart,jdbcType=BIT}, #{options,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="io.metersphere.project.domain.CustomField">
    insert into custom_field
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="scene != null">
        scene,
      </if>
      <if test="type != null">
        `type`,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="system != null">
        `system`,
      </if>
      <if test="global != null">
        `global`,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="thirdPart != null">
        third_part,
      </if>
      <if test="options != null">
        `options`,
      </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="scene != null">
        #{scene,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="system != null">
        #{system,jdbcType=BIT},
      </if>
      <if test="global != null">
        #{global,jdbcType=BIT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=BIGINT},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        #{projectId,jdbcType=VARCHAR},
      </if>
      <if test="thirdPart != null">
        #{thirdPart,jdbcType=BIT},
      </if>
      <if test="options != null">
        #{options,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="io.metersphere.project.domain.CustomFieldExample" resultType="java.lang.Long">
    select count(*) from custom_field
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update custom_field
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.name != null">
        `name` = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.scene != null">
        scene = #{record.scene,jdbcType=VARCHAR},
      </if>
      <if test="record.type != null">
        `type` = #{record.type,jdbcType=VARCHAR},
      </if>
      <if test="record.remark != null">
        remark = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.system != null">
        `system` = #{record.system,jdbcType=BIT},
      </if>
      <if test="record.global != null">
        `global` = #{record.global,jdbcType=BIT},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=BIGINT},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=BIGINT},
      </if>
      <if test="record.createUser != null">
        create_user = #{record.createUser,jdbcType=VARCHAR},
      </if>
      <if test="record.projectId != null">
        project_id = #{record.projectId,jdbcType=VARCHAR},
      </if>
      <if test="record.thirdPart != null">
        third_part = #{record.thirdPart,jdbcType=BIT},
      </if>
      <if test="record.options != null">
        `options` = #{record.options,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update custom_field
    set id = #{record.id,jdbcType=VARCHAR},
      `name` = #{record.name,jdbcType=VARCHAR},
      scene = #{record.scene,jdbcType=VARCHAR},
      `type` = #{record.type,jdbcType=VARCHAR},
      remark = #{record.remark,jdbcType=VARCHAR},
      `system` = #{record.system,jdbcType=BIT},
      `global` = #{record.global,jdbcType=BIT},
      create_time = #{record.createTime,jdbcType=BIGINT},
      update_time = #{record.updateTime,jdbcType=BIGINT},
      create_user = #{record.createUser,jdbcType=VARCHAR},
      project_id = #{record.projectId,jdbcType=VARCHAR},
      third_part = #{record.thirdPart,jdbcType=BIT},
      `options` = #{record.options,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update custom_field
    set id = #{record.id,jdbcType=VARCHAR},
      `name` = #{record.name,jdbcType=VARCHAR},
      scene = #{record.scene,jdbcType=VARCHAR},
      `type` = #{record.type,jdbcType=VARCHAR},
      remark = #{record.remark,jdbcType=VARCHAR},
      `system` = #{record.system,jdbcType=BIT},
      `global` = #{record.global,jdbcType=BIT},
      create_time = #{record.createTime,jdbcType=BIGINT},
      update_time = #{record.updateTime,jdbcType=BIGINT},
      create_user = #{record.createUser,jdbcType=VARCHAR},
      project_id = #{record.projectId,jdbcType=VARCHAR},
      third_part = #{record.thirdPart,jdbcType=BIT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="io.metersphere.project.domain.CustomField">
    update custom_field
    <set>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="scene != null">
        scene = #{scene,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        `type` = #{type,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="system != null">
        `system` = #{system,jdbcType=BIT},
      </if>
      <if test="global != null">
        `global` = #{global,jdbcType=BIT},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=BIGINT},
      </if>
      <if test="createUser != null">
        create_user = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId,jdbcType=VARCHAR},
      </if>
      <if test="thirdPart != null">
        third_part = #{thirdPart,jdbcType=BIT},
      </if>
      <if test="options != null">
        `options` = #{options,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.project.domain.CustomField">
    update custom_field
    set `name` = #{name,jdbcType=VARCHAR},
      scene = #{scene,jdbcType=VARCHAR},
      `type` = #{type,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      `system` = #{system,jdbcType=BIT},
      `global` = #{global,jdbcType=BIT},
      create_time = #{createTime,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=BIGINT},
      create_user = #{createUser,jdbcType=VARCHAR},
      project_id = #{projectId,jdbcType=VARCHAR},
      third_part = #{thirdPart,jdbcType=BIT},
      `options` = #{options,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="io.metersphere.project.domain.CustomField">
    update custom_field
    set `name` = #{name,jdbcType=VARCHAR},
      scene = #{scene,jdbcType=VARCHAR},
      `type` = #{type,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      `system` = #{system,jdbcType=BIT},
      `global` = #{global,jdbcType=BIT},
      create_time = #{createTime,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=BIGINT},
      create_user = #{createUser,jdbcType=VARCHAR},
      project_id = #{projectId,jdbcType=VARCHAR},
      third_part = #{thirdPart,jdbcType=BIT}
    where id = #{id,jdbcType=VARCHAR}
  </update>
</mapper>