<?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-24 16:58:39  -->
<mapper namespace="net.northking.cctp.dataPool.db.dao.DataSetsDao">


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

  <resultMap id="DetailMap" type="net.northking.cctp.dataPool.dto.dataSets.DataSetsDetailDto">
      <!-- 数据集id -->
    <id column="data_set_id" jdbcType="VARCHAR" property="dataSetId"/>
                                <!-- 数据集名称 -->
    <result column="name" jdbcType="VARCHAR" property="name"/>
        <!-- 描述 -->
    <result column="description" jdbcType="VARCHAR" property="description"/>
        <!-- 系统id -->
    <result column="pro_id" jdbcType="VARCHAR" property="proId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 文件地址 -->
    <result column="file_addr" jdbcType="VARCHAR" property="fileAddr"/>
        <!-- 目录id -->
    <result column="tree_id" jdbcType="VARCHAR" property="treeId"/>
        <!-- 创建人 -->
    <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.dataPool.db.entity.DataSets">
    select
    data_set_id
    ,name
    ,description
    ,pro_id
    ,tenant_id
    ,file_addr
    ,tree_id
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="dataSetId != null">
        AND data_set_id = #{dataSetId,jdbcType=VARCHAR}
      </if>
      <if test="name != null">
        AND name = #{name,jdbcType=VARCHAR}
      </if>
      <if test="description != null">
        AND description = #{description,jdbcType=VARCHAR}
      </if>
      <if test="proId != null">
        AND pro_id = #{proId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="fileAddr != null">
        AND file_addr = #{fileAddr,jdbcType=VARCHAR}
      </if>
      <if test="treeId != null">
        AND tree_id = #{treeId,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="queryDataSets" resultMap="DetailMap" parameterType="net.northking.cctp.dataPool.dto.dataSets.DataSetsQueryDto">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="query.name != null and query.name != ''">
        AND LOCATE(#{query.name,jdbcType=VARCHAR},name) &gt; 0
      </if>
      <if test="query.treeId != null and query.treeId != ''">
        AND tree_id = #{query.treeId,jdbcType=VARCHAR}
      </if>
      <if test="query.tenantId != null and query.tenantId != ''">
        AND tenant_id = #{query.tenantId,jdbcType=VARCHAR}
      </if>
      <if test="query.proIds != null and query.proIds.size > 0">
        AND pro_id IN
        <foreach collection="query.proIds" open="(" index="index" item="item" close=")" separator=",">
          #{item,jdbcType=VARCHAR}
        </foreach>
      </if>
      <if test="query.treeIds != null and query.treeIds.size > 0">
        AND tree_id IN
        <foreach collection="query.treeIds" open="(" index="index" item="item" close=")" separator=",">
          #{item,jdbcType=VARCHAR}
        </foreach>
      </if>
    </trim>
    order by created_time desc
  </select>
  <select id="queryByIds" resultMap="DetailMap" parameterType="list">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="setIds != null and setIds.size > 0">
        AND data_set_id IN
        <foreach collection="setIds" open="(" index="index" item="item" close=")" separator=",">
          #{item,jdbcType=VARCHAR}
        </foreach>
      </if>
    </trim>
  </select>
  <delete id="deleteByIds" parameterType="list">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="setIds != null and setIds.size > 0">
        AND data_set_id IN
        <foreach collection="setIds" open="(" index="index" item="item" close=")" separator=",">
          #{item,jdbcType=VARCHAR}
        </foreach>
      </if>
    </trim>
  </delete>
</mapper>