<?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-12-06 10:53:48  -->
<mapper namespace="net.northking.cctp.scriptcase.db.dao.LibraryBusComTreeDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.scriptcase.db.entity.LibraryBusComTree">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                        <!-- 树目录名称 -->
    <result column="tree_name" jdbcType="VARCHAR" property="treeName"/>
        <!-- 父节点 -->
    <result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
        <!-- 树节点等级 -->
    <result column="level_no" jdbcType="INTEGER" property="levelNo"/>
        <!-- id路径 -->
    <result column="id_path" jdbcType="VARCHAR" property="idPath"/>
        <!-- 是否为叶子节点0-否1是 -->
    <result column="is_leaf" jdbcType="INTEGER" property="isLeaf"/>
        <!-- 描述 -->
    <result column="memo" jdbcType="VARCHAR" property="memo"/>
        <!-- 中文名目录 -->
    <result column="name_path" jdbcType="VARCHAR" property="namePath"/>
        <!-- 顺序 -->
    <result column="order_seq" jdbcType="INTEGER" property="orderSeq"/>
        <!-- 是否删除0-否1-是 -->
    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
        <!-- 创建人 -->
    <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"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tree_name
    ,parent_id
    ,level_no
    ,id_path
    ,is_leaf
    ,memo
    ,name_path
    ,order_seq
    ,is_deleted
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,tenant_id
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.library_bus_com_tree
  </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>
  </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.LibraryBusComTree">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="treeName != null">
          AND tree_name=#{treeName,jdbcType=VARCHAR}
      </if>
      <if test="parentId != null">
          AND parent_id=#{parentId,jdbcType=VARCHAR}
      </if>
      <if test="levelNo != null">
          AND level_no=#{levelNo,jdbcType=INTEGER}
      </if>
      <if test="idPath != null">
          AND id_path=#{idPath,jdbcType=VARCHAR}
      </if>
      <if test="isLeaf != null">
          AND is_leaf=#{isLeaf,jdbcType=INTEGER}
      </if>
      <if test="memo != null">
          AND memo=#{memo,jdbcType=VARCHAR}
      </if>
      <if test="namePath != null">
          AND name_path=#{namePath,jdbcType=VARCHAR}
      </if>
      <if test="orderSeq != null">
          AND order_seq=#{orderSeq,jdbcType=INTEGER}
      </if>
      <if test="isDeleted != null">
          AND is_deleted=#{isDeleted,jdbcType=INTEGER}
      </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>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.scriptcase.db.entity.LibraryBusComTree">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="treeName != null">
        tree_name,
      </if>
      <if test="parentId != null">
        parent_id,
      </if>
      <if test="levelNo != null">
        level_no,
      </if>
      <if test="idPath != null">
        id_path,
      </if>
      <if test="isLeaf != null">
        is_leaf,
      </if>
      <if test="memo != null">
        memo,
      </if>
      <if test="namePath != null">
        name_path,
      </if>
      <if test="orderSeq != null">
        order_seq,
      </if>
      <if test="isDeleted != null">
        is_deleted,
      </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>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="treeName != null">
          #{treeName, jdbcType=VARCHAR},
      </if>
      <if test="parentId != null">
          #{parentId, jdbcType=VARCHAR},
      </if>
      <if test="levelNo != null">
          #{levelNo, jdbcType=INTEGER},
      </if>
      <if test="idPath != null">
          #{idPath, jdbcType=VARCHAR},
      </if>
      <if test="isLeaf != null">
          #{isLeaf, jdbcType=INTEGER},
      </if>
      <if test="memo != null">
          #{memo, jdbcType=VARCHAR},
      </if>
      <if test="namePath != null">
          #{namePath, jdbcType=VARCHAR},
      </if>
      <if test="orderSeq != null">
          #{orderSeq, jdbcType=INTEGER},
      </if>
      <if test="isDeleted != null">
          #{isDeleted, jdbcType=INTEGER},
      </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>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    tree_name,
    parent_id,
    level_no,
    id_path,
    is_leaf,
    memo,
    name_path,
    order_seq,
    is_deleted,
    created_by,
    created_time,
    updated_by,
    updated_time,
    tenant_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.treeName, jdbcType=VARCHAR},
    #{item.parentId, jdbcType=VARCHAR},
    #{item.levelNo, jdbcType=INTEGER},
    #{item.idPath, jdbcType=VARCHAR},
    #{item.isLeaf, jdbcType=INTEGER},
    #{item.memo, jdbcType=VARCHAR},
    #{item.namePath, jdbcType=VARCHAR},
    #{item.orderSeq, jdbcType=INTEGER},
    #{item.isDeleted, jdbcType=INTEGER},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
    #{item.tenantId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.scriptcase.db.entity.LibraryBusComTree">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="treeName != null">
        tree_name = #{treeName, jdbcType=VARCHAR},
      </if>
      <if test="parentId != null">
        parent_id = #{parentId, jdbcType=VARCHAR},
      </if>
      <if test="levelNo != null">
        level_no = #{levelNo, jdbcType=INTEGER},
      </if>
      <if test="idPath != null">
        id_path = #{idPath, jdbcType=VARCHAR},
      </if>
      <if test="isLeaf != null">
        is_leaf = #{isLeaf, jdbcType=INTEGER},
      </if>
      <if test="memo != null">
        memo = #{memo, jdbcType=VARCHAR},
      </if>
      <if test="namePath != null">
        name_path = #{namePath, jdbcType=VARCHAR},
      </if>
      <if test="orderSeq != null">
        order_seq = #{orderSeq, jdbcType=INTEGER},
      </if>
      <if test="isDeleted != null">
        is_deleted = #{isDeleted, jdbcType=INTEGER},
      </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 id = #{id,jdbcType=VARCHAR}
    AND tenant_id = #{tenantId,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.scriptcase.db.entity.LibraryBusComTree">
    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="treeName != null">
        AND tree_name = #{treeName,jdbcType=VARCHAR}
      </if>
      <if test="parentId != null">
        AND parent_id = #{parentId,jdbcType=VARCHAR}
      </if>
      <if test="levelNo != null">
        AND level_no = #{levelNo,jdbcType=INTEGER}
      </if>
      <if test="idPath != null">
        AND id_path = #{idPath,jdbcType=VARCHAR}
      </if>
      <if test="isLeaf != null">
        AND is_leaf = #{isLeaf,jdbcType=INTEGER}
      </if>
      <if test="memo != null">
        AND memo = #{memo,jdbcType=VARCHAR}
      </if>
      <if test="namePath != null">
        AND name_path = #{namePath,jdbcType=VARCHAR}
      </if>
      <if test="orderSeq != null">
        AND order_seq = #{orderSeq,jdbcType=INTEGER}
      </if>
      <if test="isDeleted != null">
        AND is_deleted = #{isDeleted,jdbcType=INTEGER}
      </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>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.scriptcase.db.entity.LibraryBusComTree">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="treeName != null">
        AND tree_name=#{treeName,jdbcType=VARCHAR}
      </if>
      <if test="parentId != null">
        AND parent_id=#{parentId,jdbcType=VARCHAR}
      </if>
      <if test="levelNo != null">
        AND level_no=#{levelNo,jdbcType=INTEGER}
      </if>
      <if test="idPath != null">
        AND id_path=#{idPath,jdbcType=VARCHAR}
      </if>
      <if test="isLeaf != null">
        AND is_leaf=#{isLeaf,jdbcType=INTEGER}
      </if>
      <if test="memo != null">
        AND memo=#{memo,jdbcType=VARCHAR}
      </if>
      <if test="namePath != null">
        AND name_path=#{namePath,jdbcType=VARCHAR}
      </if>
      <if test="orderSeq != null">
        AND order_seq=#{orderSeq,jdbcType=INTEGER}
      </if>
      <if test="isDeleted != null">
        AND is_deleted=#{isDeleted,jdbcType=INTEGER}
      </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>
    </trim>
  </select>

</mapper>