<?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.AtuScriptTagDao">


  <!-- 请在本文件内添加自定义SQL语句 -->
  <resultMap id="resultMap" type="net.northking.cctp.scriptcase.dto.atuScript.atuScriptTag.AtuScriptTagDto">
    <result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
    <collection property="tagIdList" ofType="net.northking.cctp.scriptcase.dto.atuScript.atuScriptTag.TagInfoDto" >
      <result column="tag_id" jdbcType="VARCHAR" property="tagId"/>
    </collection>
  </resultMap>

  <resultMap id="DetailMap" type="net.northking.cctp.scriptcase.dto.atuScript.atuScriptTag.AtuScriptTagDetailDto">
        <!-- 标签ID -->
    <id column="tag_id" jdbcType="VARCHAR" property="tagId"/>
                    <!-- 脚本ID -->
    <result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
            <!-- 系统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>

  <select id="pagingQuery" resultMap="DetailMap" parameterType="net.northking.cctp.scriptcase.db.entity.AtuScriptTag">
    select
    script_id
    ,tag_id
    ,project_id
    ,tenent_id
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="scriptId != null">
        AND script_id = #{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="tagId != null">
        AND tag_id = #{tagId,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="getTagListByIds" parameterType="list" resultMap="resultMap">
    select
    script_id,tag_id
    from
    <include refid="Table_Name"/>
    where script_id in
    <foreach collection="scriptIdList" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </select>
  <delete id="deleteScriptTagByTagList" parameterType="string">
    delete from
    <include refid="Table_Name"/>
    where tag_id in
    <foreach collection="tagList" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </delete>
</mapper>