<?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-01-31 17:10:50  -->
<mapper namespace="net.northking.cctp.scriptcase.db.dao.AtuSceneNodeInfoDao">

  <!-- 请在本文件内添加自定义SQL语句 -->

  <resultMap id="DetailMap" type="net.northking.cctp.scriptcase.dto.sceneScript.AtuSceneNodeInfoDetailDto">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                              <!-- 场景脚本ID -->
    <result column="scene_script_id" jdbcType="VARCHAR" property="sceneScriptId"/>
        <!-- 节点脚本ID -->
    <result column="node_script_id" jdbcType="VARCHAR" property="nodeScriptId"/>
        <!-- 系统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"/>
        <!-- 是否删除 -->
    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
    </resultMap>

  <select id="pagingQuery" resultMap="DetailMap" parameterType="net.northking.cctp.scriptcase.db.entity.AtuSceneNodeInfo">
    select
    id
    ,scene_script_id
    ,node_script_id
    ,project_id
    ,tenant_id
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,is_deleted
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=VARCHAR}
      </if>
      <if test="sceneScriptId != null">
        AND scene_script_id = #{sceneScriptId,jdbcType=VARCHAR}
      </if>
      <if test="nodeScriptId != null">
        AND node_script_id = #{nodeScriptId,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="isDeleted != null">
        AND is_deleted = #{isDeleted,jdbcType=INTEGER}
      </if>
    </trim>
  </select>


  <sql id="TABLE_SCRIPT_INFO">
    ${defaultSchema}.atu_script_info
  </sql>

  <select id="queryScriptType" resultType="net.northking.cctp.scriptcase.db.entity.AtuScriptInfo"
          parameterType="java.util.List">
    select
    info.*
    from
    <include refid="Table_Name" /> node
    left join
    <include refid="TABLE_SCRIPT_INFO"/> info
    on node.node_script_id = info.id
    where node.scene_script_id
    in
    <foreach collection="sceneIds" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
    and info.is_deleted = 0
  </select>

  <select id="queryNodeInfoByIds" resultMap="BaseResultMap" parameterType="java.util.List">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where
    is_deleted = 0
    and node_script_id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </select>
</mapper>