<?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-23 17:53:02  -->
<mapper namespace="net.northking.cctp.dataPool.db.dao.DataSetEnvRelDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dataPool.db.entity.DataSetEnvRel">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                              <!-- 数据集id -->
    <result column="data_set_id" jdbcType="VARCHAR" property="dataSetId"/>
        <!-- 环境id -->
    <result column="env_id" jdbcType="VARCHAR" property="envId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 排序 -->
    <result column="seq" jdbcType="INTEGER" property="seq"/>
        <!-- 创建时间 -->
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <!-- 创建人 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 更新时间 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <!-- 更新人 -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
        <!-- 文件地址 -->
    <result column="file_addr" jdbcType="VARCHAR" property="fileAddr"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,data_set_id
    ,env_id
    ,tenant_id
    ,seq
    ,created_time
    ,created_by
    ,updated_time
    ,updated_by
    ,file_addr
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.data_set_env_rel
  </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.dataPool.db.entity.DataSetEnvRel">
    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="dataSetId != null">
          AND data_set_id=#{dataSetId,jdbcType=VARCHAR}
        </if>
              <if test="envId != null">
          AND env_id=#{envId,jdbcType=VARCHAR}
        </if>
              <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
        </if>
              <if test="seq != null">
          AND seq=#{seq,jdbcType=INTEGER}
        </if>
              <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=TIMESTAMP}
        </if>
              <if test="createdBy != null">
          AND created_by=#{createdBy,jdbcType=VARCHAR}
        </if>
              <if test="updatedTime != null">
          AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
        </if>
              <if test="updatedBy != null">
          AND updated_by=#{updatedBy,jdbcType=VARCHAR}
        </if>
              <if test="fileAddr != null">
          AND file_addr=#{fileAddr,jdbcType=VARCHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dataPool.db.entity.DataSetEnvRel">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="dataSetId != null">
        data_set_id,
      </if>
      <if test="envId != null">
        env_id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="seq != null">
        seq,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="fileAddr != null">
        file_addr,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="dataSetId != null">
          #{dataSetId, jdbcType=VARCHAR},
      </if>
      <if test="envId != null">
          #{envId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="seq != null">
          #{seq, jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
          #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
          #{updatedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
          #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="fileAddr != null">
          #{fileAddr, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    data_set_id,
    env_id,
    tenant_id,
    seq,
    created_time,
    created_by,
    updated_time,
    updated_by,
    file_addr,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.dataSetId, jdbcType=VARCHAR},
    #{item.envId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.seq, jdbcType=INTEGER},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.fileAddr, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dataPool.db.entity.DataSetEnvRel">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="dataSetId != null">
        data_set_id = #{dataSetId, jdbcType=VARCHAR},
      </if>
      <if test="envId != null">
        env_id = #{envId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="seq != null">
        seq = #{seq, jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="fileAddr != null">
        file_addr = #{fileAddr, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dataPool.db.entity.DataSetEnvRel">
    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="dataSetId != null">
        AND data_set_id = #{dataSetId,jdbcType=VARCHAR}
      </if>
      <if test="envId != null">
        AND env_id = #{envId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="seq != null">
        AND seq = #{seq,jdbcType=INTEGER}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time = #{updatedTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by = #{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="fileAddr != null">
        AND file_addr = #{fileAddr,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dataPool.db.entity.DataSetEnvRel">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="dataSetId != null">
        AND data_set_id=#{dataSetId,jdbcType=VARCHAR}
      </if>
      <if test="envId != null">
        AND env_id=#{envId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="seq != null">
        AND seq=#{seq,jdbcType=INTEGER}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by=#{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="fileAddr != null">
        AND file_addr=#{fileAddr,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>