<?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-21 10:17:44  -->
<mapper namespace="net.northking.cctp.scriptcase.db.dao.AtuScriptInfoDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.scriptcase.db.entity.AtuScriptInfo">
    <!-- 脚本ID -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
    <!-- 脚本目录ID -->
    <result column="group_id" jdbcType="VARCHAR" property="groupId"/>
    <!-- 脚本名称 -->
    <result column="script_name" jdbcType="VARCHAR" property="scriptName"/>
    <!-- 脚本编号 -->
    <result column="script_code" jdbcType="VARCHAR" property="scriptCode"/>
    <!-- 脚本类型 -->
    <result column="script_type" jdbcType="VARCHAR" property="scriptType"/>
    <!-- 最新版本ID -->
    <result column="latest_version_id" jdbcType="INTEGER" property="latestVersionId"/>
    <!-- 脚本地址 -->
    <result column="script_url" jdbcType="VARCHAR" property="scriptUrl"/>
    <!-- 脚本快照数据地址 -->
    <result column="data_url" jdbcType="VARCHAR" property="dataUrl"/>
    <!-- 是否删除 -->
    <result column="is_deleted" jdbcType="VARCHAR" property="isDeleted"/>
    <!-- 系统ID -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
    <!-- 租户号 -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    <!-- 创建人 -->
    <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"/>
    <!-- 应用ID -->
    <result column="app_id" jdbcType="VARCHAR" property="appId"/>
    <!-- 应用包名 -->
    <result column="app_package" jdbcType="VARCHAR" property="appPackage"/>
    <!-- 应用系统(0-安卓 1-IOS 2-鸿蒙) -->
    <result column="platform" jdbcType="VARCHAR" property="platform"/>
    <!-- 负责人 -->
    <result column="principalId" jdbcType="VARCHAR" property="principalId"/>
  </resultMap>

  <sql id="Base_Column_List">
    id
    ,group_id
    ,script_name
    ,script_code
    ,script_type
    ,latest_version_id
    ,script_url
    ,data_url
    ,is_deleted
    ,project_id
    ,tenant_id
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,app_id
    ,app_package
    ,platform
    ,principal_id
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.atu_script_info
  </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" resultMap="BaseResultMap">
    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>
    and is_deleted = 0
  </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.AtuScriptInfo">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="groupId != null">
        AND group_id=#{groupId,jdbcType=VARCHAR}
      </if>
      <if test="scriptName != null">
        AND script_name=#{scriptName,jdbcType=VARCHAR}
      </if>
      <if test="scriptCode != null">
        AND script_code=#{scriptCode,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type=#{scriptType,jdbcType=VARCHAR}
      </if>
      <if test="latestVersionId != null">
        AND latest_version_id=#{latestVersionId,jdbcType=INTEGER}
      </if>
      <if test="scriptUrl != null">
        AND script_url=#{scriptUrl,jdbcType=VARCHAR}
      </if>
      <if test="dataUrl != null">
        AND data_url=#{dataUrl,jdbcType=VARCHAR}
      </if>
      <if test="isDeleted != null">
        AND is_deleted=#{isDeleted,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,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>
      <if test="appId != null">
        AND app_id=#{appId,jdbcType=VARCHAR}
      </if>
      <if test="appPackage != null">
        AND app_package=#{appPackage,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
        AND platform=#{platform,jdbcType=VARCHAR}
      </if>
      <if test="principalId != null">
        AND principal_id=#{principalId,jdbcType=VARCHAR}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptInfo">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="groupId != null">
        group_id,
      </if>
      <if test="scriptName != null">
        script_name,
      </if>
      <if test="scriptCode != null">
        script_code,
      </if>
      <if test="scriptType != null">
        script_type,
      </if>
      <if test="latestVersionId != null">
        latest_version_id,
      </if>
      <if test="scriptUrl != null">
        script_url,
      </if>
      <if test="dataUrl != null">
        data_url,
      </if>
      <if test="isDeleted != null">
        is_deleted,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="tenantId != null">
        tenant_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>
      <if test="appId != null">
        app_id,
      </if>
      <if test="appPackage != null">
        app_package,
      </if>
      <if test="platform != null">
        platform,
      </if>
      <if test="principalId != null">
        principal_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id, jdbcType=VARCHAR},
      </if>
      <if test="groupId != null">
        #{groupId, jdbcType=VARCHAR},
      </if>
      <if test="scriptName != null">
        #{scriptName, jdbcType=VARCHAR},
      </if>
      <if test="scriptCode != null">
        #{scriptCode, jdbcType=VARCHAR},
      </if>
      <if test="scriptType != null">
        #{scriptType, jdbcType=VARCHAR},
      </if>
      <if test="latestVersionId != null">
        #{latestVersionId, jdbcType=INTEGER},
      </if>
      <if test="scriptUrl != null">
        #{scriptUrl, jdbcType=VARCHAR},
      </if>
      <if test="dataUrl != null">
        #{dataUrl, jdbcType=VARCHAR},
      </if>
      <if test="isDeleted != null">
        #{isDeleted, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
        #{tenantId, 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>
      <if test="appId != null">
        #{appId, jdbcType=VARCHAR},
      </if>
      <if test="appPackage != null">
        #{appPackage, jdbcType=VARCHAR},
      </if>
      <if test="platform != null">
        #{platform,jdbcType=VARCHAR},
      </if>
      <if test="principalId != null">
        #{principalId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      id,
      group_id,
      script_name,
      script_code,
      script_type,
      latest_version_id,
      script_url,
      data_url,
      is_deleted,
      project_id,
      tenant_id,
      created_by,
      created_time,
      updated_by,
      updated_time,
      app_id,
      app_package,
      platform,
      principal_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
        #{item.id, jdbcType=VARCHAR},
        #{item.groupId, jdbcType=VARCHAR},
        #{item.scriptName, jdbcType=VARCHAR},
        #{item.scriptCode, jdbcType=VARCHAR},
        #{item.scriptType, jdbcType=VARCHAR},
        #{item.latestVersionId, jdbcType=INTEGER},
        #{item.scriptUrl, jdbcType=VARCHAR},
        #{item.dataUrl, jdbcType=VARCHAR},
        #{item.isDeleted, jdbcType=VARCHAR},
        #{item.projectId, jdbcType=VARCHAR},
        #{item.tenantId, jdbcType=VARCHAR},
        #{item.createdBy, jdbcType=VARCHAR},
        #{item.createdTime, jdbcType=TIMESTAMP},
        #{item.updatedBy, jdbcType=VARCHAR},
        #{item.updatedTime, jdbcType=TIMESTAMP},
        #{item.appId, jdbcType=VARCHAR},
        #{item.appPackage, jdbcType=VARCHAR},
        #{item.platform, jdbcType=VARCHAR},
        #{item.principalId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptInfo">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="groupId != null">
       group_id = #{groupId, jdbcType=VARCHAR},
      </if>
      <if test="scriptName != null">
       script_name = #{scriptName, jdbcType=VARCHAR},
      </if>
      <if test="scriptCode != null">
        script_code = #{scriptCode, jdbcType=VARCHAR},
      </if>
      <if test="scriptType != null">
       script_type = #{scriptType, jdbcType=VARCHAR},
      </if>
      <if test="latestVersionId != null">
       latest_version_id = #{latestVersionId, jdbcType=INTEGER},
      </if>
      <if test="scriptUrl != null">
       script_url = #{scriptUrl, jdbcType=VARCHAR},
      </if>
      <if test="dataUrl != null">
       data_url = #{dataUrl, jdbcType=VARCHAR},
      </if>
      <if test="isDeleted != null">
       is_deleted = #{isDeleted, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
       project_id = #{projectId, 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>
      <if test="appId != null">
       app_id = #{appId, jdbcType=VARCHAR},
      </if>
      <if test="appPackage != null">
       app_package = #{appPackage, jdbcType=VARCHAR},
      </if>
      <if test="platform != null">
       platform=#{platform,jdbcType=VARCHAR},
      </if>
      <if test="principalId != null">
        principal_id=#{principalId,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptInfo">
    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="groupId != null">
        AND group_id = #{groupId,jdbcType=VARCHAR}
      </if>
      <if test="scriptName != null">
        AND script_name = #{scriptName,jdbcType=VARCHAR}
      </if>
      <if test="scriptCode != null">
        AND script_code = #{scriptCode,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type = #{scriptType,jdbcType=VARCHAR}
      </if>
      <if test="latestVersionId != null">
        AND latest_version_id = #{latestVersionId,jdbcType=INTEGER}
      </if>
      <if test="scriptUrl != null">
        AND script_url = #{scriptUrl,jdbcType=VARCHAR}
      </if>
      <if test="dataUrl != null">
        AND data_url = #{dataUrl,jdbcType=VARCHAR}
      </if>
      <if test="isDeleted != null">
        AND is_deleted = #{isDeleted,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,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>
      <if test="appId != null">
        AND app_id = #{appId,jdbcType=VARCHAR}
      </if>
      <if test="appPackage != null">
        AND app_package = #{appPackage,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
        AND platform=#{platform,jdbcType=VARCHAR}
      </if>
      <if test="principalId != null">
        AND principal_id=#{principalId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptInfo">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="groupId != null">
        AND group_id=#{groupId,jdbcType=VARCHAR}
      </if>
      <if test="scriptName != null">
        AND script_name=#{scriptName,jdbcType=VARCHAR}
      </if>
      <if test="scriptCode != null">
        AND script_code = #{scriptCode,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type=#{scriptType,jdbcType=VARCHAR}
      </if>
      <if test="latestVersionId != null">
        AND latest_version_id=#{latestVersionId,jdbcType=INTEGER}
      </if>
      <if test="scriptUrl != null">
        AND script_url=#{scriptUrl,jdbcType=VARCHAR}
      </if>
      <if test="dataUrl != null">
        AND data_url=#{dataUrl,jdbcType=VARCHAR}
      </if>
      <if test="isDeleted != null">
        AND is_deleted=#{isDeleted,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,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>
      <if test="appId != null">
        AND app_id=#{appId,jdbcType=VARCHAR}
      </if>
      <if test="appPackage != null">
        AND app_package=#{appPackage,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
        AND platform=#{platform,jdbcType=VARCHAR}
      </if>
      <if test="principalId != null">
        AND principal_id=#{principalId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>