<?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 2023 . All rights reserved. -->
<!--  Mybatis数据库持久层（底层映射文件）：用例集目录表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2023-08-26 14:52:39  -->
<mapper namespace="net.northking.cctp.scriptcase.db.dao.AtuCaseDataSetDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.scriptcase.db.entity.AtuCaseDataSet">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                  <!-- 目录名称 -->
    <result column="set_name" jdbcType="VARCHAR" property="setName"/>
        <!-- 系统id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 脚本id -->
    <result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
        <!-- 路径 -->
    <result column="path" jdbcType="VARCHAR" property="path"/>
        <!-- 是否叶子节点 -->
    <result column="is_leaf" jdbcType="TINYINT" property="leaf"/>

    <result column="version" jdbcType="VARCHAR" property="version"/>
    <!-- 目录层级 -->
    <result column="level_no" jdbcType="INTEGER" property="levelNo"/>
    <!-- 目录层级 -->
    <result column="idx" jdbcType="INTEGER" property="idx"/>
        <!-- 父节点 -->
    <result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
        <!-- 创建人 -->
    <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="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 负责人id -->
    <result column="principal_id" jdbcType="VARCHAR" property="principalId"/>

    <result column="script_type" jdbcType="VARCHAR" property="scriptType"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,set_name
    ,project_id
    ,script_id
    ,path
    ,is_leaf
    ,version
    ,level_no
    ,idx
    ,parent_id
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,tenant_id
    ,principal_id
    ,script_type
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.atu_case_data_set
  </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.AtuCaseDataSet">
    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="setName != null">
          AND set_name=#{setName,jdbcType=VARCHAR}
        </if>
              <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
        </if>
              <if test="scriptId != null">
          AND script_id=#{scriptId,jdbcType=VARCHAR}
        </if>
              <if test="path != null">
          AND path=#{path,jdbcType=VARCHAR}
        </if>
              <if test="leaf != null">
          AND is_leaf=#{leaf,jdbcType=TINYINT}
        </if>
              <if test="version != null">
          AND version=#{version,jdbcType=VARCHAR}
        </if>
              <if test="levelNo != null">
          AND level_no=#{levelNo,jdbcType=INTEGER}
        </if>
              <if test="idx != null">
          AND idx=#{idx,jdbcType=INTEGER}
        </if>
              <if test="parentId != null">
          AND parent_id=#{parentId,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="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
        </if>
              <if test="principalId != null">
          AND principal_id=#{principalId,jdbcType=VARCHAR}
        </if>
              <if test="scriptType != null">
          AND script_type=#{scriptType,jdbcType=VARCHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.scriptcase.db.entity.AtuCaseDataSet">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="setName != null">
        set_name,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="scriptId != null">
        script_id,
      </if>
      <if test="path != null">
        path,
      </if>
      <if test="leaf != null">
        is_leaf,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="levelNo != null">
        level_no,
      </if>
      <if test="idx != null">
        idx,
      </if>
      <if test="parentId != null">
        parent_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="tenantId != null">
        tenant_id,
      </if>
      <if test="principalId != null">
        principal_id,
      </if>
      <if test="scriptType != null">
        script_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="setName != null">
          #{setName, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="scriptId != null">
          #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="path != null">
          #{path, jdbcType=VARCHAR},
      </if>
      <if test="leaf != null">
          #{leaf, jdbcType=TINYINT},
      </if>
      <if test="version != null">
        #{version, jdbcType=VARCHAR},
      </if>
      <if test="levelNo != null">
          #{levelNo, jdbcType=INTEGER}
      </if>
      <if test="idx != null">
          #{idx, jdbcType=INTEGER}
      </if>
      <if test="parentId != null">
          #{parentId, 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="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="principalId != null">
        #{principalId, jdbcType=VARCHAR},
      </if>
      <if test="scriptType != null">
        #{scriptType, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    set_name,
    project_id,
    script_id,
    path,
    is_leaf,
    level_no,
    version,
    idx,
    parent_id,
    created_by,
    created_time,
    updated_by,
    updated_time,
    tenant_id,
    principal_id,
    script_type,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.setName, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.scriptId, jdbcType=VARCHAR},
    #{item.path, jdbcType=VARCHAR},
    #{item.leaf, jdbcType=TINYINT},
    #{item.levelNo, jdbcType=INTEGER},
    #{item.version, jdbcType=VARCHAR},
    #{item.idx,jdbcType=INTEGER},
    #{item.parentId, jdbcType=VARCHAR},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.principalId, jdbcType=VARCHAR},
    #{item.scriptType, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.scriptcase.db.entity.AtuCaseDataSet">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="setName != null">
        set_name = #{setName, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="scriptId != null">
        script_id = #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="path != null">
        path = #{path, jdbcType=VARCHAR},
      </if>
      <if test="leaf != null">
        is_leaf = #{leaf, jdbcType=TINYINT},
      </if>
      <if test="version != null">
        version = #{version, jdbcType=VARCHAR},
      </if>
      <if test="levelNo != null">
        level_no = #{levelNo, jdbcType=INTEGER},
      </if>
      <if test="idx != null">
        idx = #{idx, jdbcType=INTEGER},
      </if>
      <if test="parentId != null">
        parent_id = #{parentId, 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="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="principalId != null">
        principal_id = #{principalId, jdbcType=VARCHAR},
      </if>
      <if test="scriptType != null">
        script_type = #{scriptType, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.scriptcase.db.entity.AtuCaseDataSet">
    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="setName != null">
        AND set_name = #{setName,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="scriptId != null">
        AND script_id = #{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="path != null">
        AND path = #{path,jdbcType=VARCHAR}
      </if>
      <if test="leaf != null">
        AND is_leaf = #{leaf,jdbcType=TINYINT}
      </if>
      <if test="version != null">
        AND version = #{version,jdbcType=TINYINT}
      </if>
      <if test="levelNo != null">
        AND level_no = #{levelNo,jdbcType=INTEGER}
      </if>
      <if test="idx != null">
        AND idx = #{idx,jdbcType=INTEGER}
      </if>
      <if test="parentId != null">
        AND parent_id = #{parentId,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="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="principalId != null">
        AND principal_id = #{principalId,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type = #{scriptType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.scriptcase.db.entity.AtuCaseDataSet">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="setName != null">
        AND set_name=#{setName,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="scriptId != null">
        AND script_id=#{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="path != null">
        AND path=#{path,jdbcType=VARCHAR}
      </if>
      <if test="leaf != null">
        AND is_leaf=#{leaf,jdbcType=TINYINT}
      </if>
      <if test="version != null">
        AND version = #{version,jdbcType=TINYINT}
      </if>
      <if test="levelNo != null">
        AND level_no = #{levelNo,jdbcType=INTEGER}
      </if>
      <if test="idx != null">
        AND idx = #{idx,jdbcType=INTEGER}
      </if>
      <if test="parentId != null">
        AND parent_id=#{parentId,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="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="principalId != null">
        AND principal_id = #{principalId,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type = #{scriptType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>