<?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-18 17:29:31  -->
<mapper namespace="net.northking.cctp.scriptcase.db.dao.AtuScriptVersionDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.scriptcase.db.entity.AtuScriptVersion">
        <!-- 脚本版本ID -->
    <id column="version_id" jdbcType="INTEGER" property="versionId"/>
                            <!-- 脚本ID -->
    <result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
            <!-- 版本名称 -->
    <result column="version_name" jdbcType="VARCHAR" property="versionName"/>
        <!-- 脚本名称 -->
    <result column="script_name" jdbcType="VARCHAR" property="scriptName"/>
        <!-- 脚本版本内容地址 -->
    <result column="url" jdbcType="VARCHAR" property="url"/>
        <!-- 脚本版本数据地址 -->
    <result column="data_url" jdbcType="VARCHAR" property="dataUrl"/>
        <!-- 系统ID -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 租户号 -->
    <result column="tenent_id" jdbcType="VARCHAR" property="tenentId"/>
        <!-- 创建人 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 创建时间 -->
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <!-- 更新人 -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
        <!-- 更新时间 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>

  <sql id="Base_Column_List">
    script_id
    ,version_id
    ,version_name
    ,script_name
    ,url
    ,data_url
    ,project_id
    ,tenent_id
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
  </sql>

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

  <select id="findByPrimaryKey" parameterType="integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where version_id = #{versionId,jdbcType=INTEGER}
  </select>

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

  <delete id="deleteByPrimaryKey" parameterType="integer">
    delete from
    <include refid="Table_Name"/>
    where version_id = #{versionId,jdbcType=INTEGER}
  </delete>

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

  <delete id="deleteByExample" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptVersion">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="scriptId != null">
          AND script_id=#{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="versionId != null">
          AND version_id=#{versionId,jdbcType=INTEGER}
      </if>
      <if test="versionName != null">
          AND version_name=#{versionName,jdbcType=VARCHAR}
      </if>
      <if test="scriptName != null">
          AND script_name=#{scriptName,jdbcType=VARCHAR}
      </if>
      <if test="url != null">
          AND url=#{url,jdbcType=VARCHAR}
      </if>
      <if test="dataUrl != null">
          AND data_url=#{dataUrl,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenentId != null">
          AND tenent_id=#{tenentId,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
          AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
          AND updated_by=#{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
          AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptVersion">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="scriptId != null">
        script_id,
      </if>
      <if test="versionId != null">
        version_id,
      </if>
      <if test="versionName != null">
        version_name,
      </if>
      <if test="scriptName != null">
        script_name,
      </if>
      <if test="url != null">
        url,
      </if>
      <if test="dataUrl != null">
        data_url,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="tenentId != null">
        tenent_id,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="scriptId != null">
          #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="versionId != null">
          #{versionId, jdbcType=INTEGER},
      </if>
      <if test="versionName != null">
          #{versionName, jdbcType=VARCHAR},
      </if>
      <if test="scriptName != null">
          #{scriptName, jdbcType=VARCHAR},
      </if>
      <if test="url != null">
          #{url, jdbcType=VARCHAR},
      </if>
      <if test="dataUrl != null">
          #{dataUrl, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="tenentId != null">
          #{tenentId, jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
          #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
          #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
          #{updatedTime, jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    script_id,
    version_id,
    version_name,
    script_name,
    url,
    data_url,
    project_id,
    tenent_id,
    created_by,
    created_time,
    updated_by,
    updated_time,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.scriptId, jdbcType=VARCHAR},
    #{item.versionId, jdbcType=INTEGER},
    #{item.versionName, jdbcType=VARCHAR},
    #{item.scriptName, jdbcType=VARCHAR},
    #{item.url, jdbcType=VARCHAR},
    #{item.dataUrl, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.tenentId, jdbcType=VARCHAR},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptVersion">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="scriptId != null">
        script_id = #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="versionName != null">
        version_name = #{versionName, jdbcType=VARCHAR},
      </if>
      <if test="scriptName != null">
        script_name = #{scriptName, jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        url = #{url, jdbcType=VARCHAR},
      </if>
      <if test="dataUrl != null">
        data_url = #{dataUrl, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="tenentId != null">
        tenent_id = #{tenentId, jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime, jdbcType=TIMESTAMP},
      </if>
    </set>
    where version_id = #{versionId,jdbcType=INTEGER}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptVersion">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="scriptId != null">
        AND script_id = #{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="versionId != null">
        AND version_id = #{versionId,jdbcType=INTEGER}
      </if>
      <if test="versionName != null">
        AND version_name = #{versionName,jdbcType=VARCHAR}
      </if>
      <if test="scriptName != null">
        AND script_name = #{scriptName,jdbcType=VARCHAR}
      </if>
      <if test="url != null">
        AND url = #{url,jdbcType=VARCHAR}
      </if>
      <if test="dataUrl != null">
        AND data_url = #{dataUrl,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenentId != null">
        AND tenent_id = #{tenentId,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by = #{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time = #{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptVersion">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="scriptId != null">
        AND script_id=#{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="versionId != null">
        AND version_id=#{versionId,jdbcType=INTEGER}
      </if>
      <if test="versionName != null">
        AND version_name=#{versionName,jdbcType=VARCHAR}
      </if>
      <if test="scriptName != null">
        AND script_name=#{scriptName,jdbcType=VARCHAR}
      </if>
      <if test="url != null">
        AND url=#{url,jdbcType=VARCHAR}
      </if>
      <if test="dataUrl != null">
        AND data_url=#{dataUrl,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenentId != null">
        AND tenent_id=#{tenentId,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by=#{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

</mapper>