<?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">
<!--  Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved. -->
<!--  Mybatis数据库持久层（底层映射文件）：全局变量表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-10-29 11:40:19  -->
<mapper namespace="net.northking.cctp.scriptcase.db.dao.AtuGlobalVariableDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.scriptcase.db.entity.AtuGlobalVariable">
      <!--  -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                      <!-- 变量名称 -->
    <result column="name" jdbcType="VARCHAR" property="name"/>
        <!-- 数据类型 -->
    <result column="data_type" jdbcType="VARCHAR" property="dataType"/>
        <!-- 默认值 -->
    <result column="default_value" jdbcType="VARCHAR" property="defaultValue"/>
        <!-- 描述 -->
    <result column="memo" jdbcType="VARCHAR" property="memo"/>
        <!-- 是否被删除：0-未删除、1-已删除 -->
    <result column="is_delete" jdbcType="BIT" property="delete"/>
        <!-- 变量类型：0-全局变量、1-脚本变量 -->
    <result column="variable_type" jdbcType="BIT" property="variableType"/>
        <!-- 脚本变量时必填、全局变量时为空 -->
    <result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 系统id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 更新人 -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
        <!-- 更新时间 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <!-- 创建人 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 创建时间 -->
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,name
    ,data_type
    ,default_value
    ,memo
    ,is_delete
    ,variable_type
    ,script_id
    ,tenant_id
    ,project_id
    ,updated_by
    ,updated_time
    ,created_by
    ,created_time
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.atu_global_variable
  </sql>

  <select id="findByPrimaryKey" parameterType="String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=VARCHAR}
  </select>

  <select id="findByPrimaryKeys" parameterType="java.util.List">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </select>

  <delete id="deleteByPrimaryKey" parameterType="String">
    delete from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=VARCHAR}
  </delete>

  <delete id="deleteByPrimaryKeys" parameterType="String">
    delete from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </delete>

  <delete id="deleteByExample" parameterType="net.northking.cctp.scriptcase.db.entity.AtuGlobalVariable">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <choose>
        <when test="id != null">
          id = #{id,jdbcType=VARCHAR}
        </when>
      </choose>
              <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
        </if>
              <if test="name != null">
          AND name=#{name,jdbcType=VARCHAR}
        </if>
              <if test="dataType != null">
          AND data_type=#{dataType,jdbcType=VARCHAR}
        </if>
              <if test="defaultValue != null">
          AND default_value=#{defaultValue,jdbcType=VARCHAR}
        </if>
              <if test="memo != null">
          AND memo=#{memo,jdbcType=VARCHAR}
        </if>
              <if test="delete != null">
          AND is_delete=#{delete,jdbcType=BIT}
        </if>
              <if test="variableType != null">
          AND variable_type=#{variableType,jdbcType=BIT}
        </if>
              <if test="scriptId != null">
          AND script_id=#{scriptId,jdbcType=VARCHAR}
        </if>
              <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
        </if>
              <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
        </if>
              <if test="updatedBy != null">
          AND updated_by=#{updatedBy,jdbcType=VARCHAR}
        </if>
              <if test="updatedTime != null">
          AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
        </if>
              <if test="createdBy != null">
          AND created_by=#{createdBy,jdbcType=VARCHAR}
        </if>
              <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=TIMESTAMP}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.scriptcase.db.entity.AtuGlobalVariable">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="dataType != null">
        data_type,
      </if>
      <if test="defaultValue != null">
        default_value,
      </if>
      <if test="memo != null">
        memo,
      </if>
      <if test="delete != null">
        is_delete,
      </if>
      <if test="variableType != null">
        variable_type,
      </if>
      <if test="scriptId != null">
        script_id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="createdTime != null">
        created_time,
      </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="dataType != null">
          #{dataType, jdbcType=VARCHAR},
      </if>
      <if test="defaultValue != null">
          #{defaultValue, jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
          #{memo, jdbcType=VARCHAR},
      </if>
      <if test="delete != null">
          #{delete, jdbcType=BIT},
      </if>
      <if test="variableType != null">
          #{variableType, jdbcType=BIT},
      </if>
      <if test="scriptId != null">
          #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="updatedBy != null">
          #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
          #{updatedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
          #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    name,
    data_type,
    default_value,
    memo,
    is_delete,
    variable_type,
    script_id,
    tenant_id,
    project_id,
    updated_by,
    updated_time,
    created_by,
    created_time,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.name, jdbcType=VARCHAR},
    #{item.dataType, jdbcType=VARCHAR},
    #{item.defaultValue, jdbcType=VARCHAR},
    #{item.memo, jdbcType=VARCHAR},
    #{item.delete, jdbcType=BIT},
    #{item.variableType, jdbcType=BIT},
    #{item.scriptId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.scriptcase.db.entity.AtuGlobalVariable">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="name != null">
        name = #{name, jdbcType=VARCHAR},
      </if>
      <if test="dataType != null">
        data_type = #{dataType, jdbcType=VARCHAR},
      </if>
      <if test="defaultValue != null">
        default_value = #{defaultValue, jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        memo = #{memo, jdbcType=VARCHAR},
      </if>
      <if test="delete != null">
        is_delete = #{delete, jdbcType=BIT},
      </if>
      <if test="variableType != null">
        variable_type = #{variableType, jdbcType=BIT},
      </if>
      <if test="scriptId != null">
        script_id = #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.scriptcase.db.entity.AtuGlobalVariable">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=VARCHAR}
      </if>
      <if test="name != null">
        AND name = #{name,jdbcType=VARCHAR}
      </if>
      <if test="dataType != null">
        AND data_type = #{dataType,jdbcType=VARCHAR}
      </if>
      <if test="defaultValue != null">
        AND default_value = #{defaultValue,jdbcType=VARCHAR}
      </if>
      <if test="memo != null">
        AND memo = #{memo,jdbcType=VARCHAR}
      </if>
      <if test="delete != null">
        AND is_delete = #{delete,jdbcType=BIT}
      </if>
      <if test="variableType != null">
        AND variable_type = #{variableType,jdbcType=BIT}
      </if>
      <if test="scriptId != null">
        AND script_id = #{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="updatedBy != null">
        AND updated_by = #{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time = #{updatedTime,jdbcType=TIMESTAMP}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.scriptcase.db.entity.AtuGlobalVariable">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="name != null">
        AND name=#{name,jdbcType=VARCHAR}
      </if>
      <if test="dataType != null">
        AND data_type=#{dataType,jdbcType=VARCHAR}
      </if>
      <if test="defaultValue != null">
        AND default_value=#{defaultValue,jdbcType=VARCHAR}
      </if>
      <if test="memo != null">
        AND memo=#{memo,jdbcType=VARCHAR}
      </if>
      <if test="delete != null">
        AND is_delete=#{delete,jdbcType=BIT}
      </if>
      <if test="variableType != null">
        AND variable_type=#{variableType,jdbcType=BIT}
      </if>
      <if test="scriptId != null">
        AND script_id=#{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="updatedBy != null">
        AND updated_by=#{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

</mapper>