<?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. -->
<!--  文件内容由代码生成器产生，请不要手动修改！ -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2023-09-12 17:22:54  -->
<mapper namespace="net.northking.cctp.project.db.dao.CpProjectEnvDsDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.project.db.entity.CpProjectEnvDs">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                              <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 系统id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 环境id -->
    <result column="env_id" jdbcType="VARCHAR" property="envId"/>
        <!-- 数据源类型 0-MongoDB，1-mysql，2-Oracle，3-达梦，4-OceanBase，5-db2 -->
    <result column="ds_type" jdbcType="TINYINT" property="dsType"/>
        <!-- 连接名称 -->
    <result column="conn_name" jdbcType="VARCHAR" property="connName"/>
        <!-- 主机 -->
    <result column="conn_host" jdbcType="VARCHAR" property="connHost"/>
        <!-- 端口 -->
    <result column="conn_port" jdbcType="INTEGER" property="connPort"/>
        <!-- 数据库 -->
    <result column="conn_database" jdbcType="VARCHAR" property="connDatabase"/>
        <!-- 用户名 -->
    <result column="conn_username" jdbcType="VARCHAR" property="connUsername"/>
        <!-- 密码 -->
    <result column="conn_password" jdbcType="VARCHAR" property="connPassword"/>
        <!-- 高级属性 -->
    <result column="advanced_config" jdbcType="VARCHAR" property="advancedConfig"/>
        <!-- 描述 -->
    <result column="memo" jdbcType="VARCHAR" property="memo"/>
        <!-- 创建人 -->
    <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="TINYINT" property="deleted"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tenant_id
    ,project_id
    ,env_id
    ,ds_type
    ,conn_name
    ,conn_host
    ,conn_port
    ,conn_database
    ,conn_username
    ,conn_password
    ,advanced_config
    ,memo
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,is_deleted
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cp_project_env_ds
  </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.project.db.entity.CpProjectEnvDs">
    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="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
        </if>
              <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
        </if>
              <if test="envId != null">
          AND env_id=#{envId,jdbcType=VARCHAR}
        </if>
              <if test="dsType != null">
          AND ds_type=#{dsType,jdbcType=TINYINT}
        </if>
              <if test="connName != null">
          AND conn_name=#{connName,jdbcType=VARCHAR}
        </if>
              <if test="connHost != null">
          AND conn_host=#{connHost,jdbcType=VARCHAR}
        </if>
              <if test="connPort != null">
          AND conn_port=#{connPort,jdbcType=INTEGER}
        </if>
              <if test="connDatabase != null">
          AND conn_database=#{connDatabase,jdbcType=VARCHAR}
        </if>
              <if test="connUsername != null">
          AND conn_username=#{connUsername,jdbcType=VARCHAR}
        </if>
              <if test="connPassword != null">
          AND conn_password=#{connPassword,jdbcType=VARCHAR}
        </if>
              <if test="advancedConfig != null">
          AND advanced_config=#{advancedConfig,jdbcType=VARCHAR}
        </if>
              <if test="memo != null">
          AND memo=#{memo,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="deleted != null">
          AND is_deleted=#{deleted,jdbcType=TINYINT}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.project.db.entity.CpProjectEnvDs">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="envId != null">
        env_id,
      </if>
      <if test="dsType != null">
        ds_type,
      </if>
      <if test="connName != null">
        conn_name,
      </if>
      <if test="connHost != null">
        conn_host,
      </if>
      <if test="connPort != null">
        conn_port,
      </if>
      <if test="connDatabase != null">
        conn_database,
      </if>
      <if test="connUsername != null">
        conn_username,
      </if>
      <if test="connPassword != null">
        conn_password,
      </if>
      <if test="advancedConfig != null">
        advanced_config,
      </if>
      <if test="memo != null">
        memo,
      </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="deleted != null">
        is_deleted,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="envId != null">
          #{envId, jdbcType=VARCHAR},
      </if>
      <if test="dsType != null">
          #{dsType, jdbcType=TINYINT},
      </if>
      <if test="connName != null">
          #{connName, jdbcType=VARCHAR},
      </if>
      <if test="connHost != null">
          #{connHost, jdbcType=VARCHAR},
      </if>
      <if test="connPort != null">
          #{connPort, jdbcType=INTEGER},
      </if>
      <if test="connDatabase != null">
          #{connDatabase, jdbcType=VARCHAR},
      </if>
      <if test="connUsername != null">
          #{connUsername, jdbcType=VARCHAR},
      </if>
      <if test="connPassword != null">
          #{connPassword, jdbcType=VARCHAR},
      </if>
      <if test="advancedConfig != null">
          #{advancedConfig, jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
          #{memo, jdbcType=VARCHAR},
      </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="deleted != null">
          #{deleted, jdbcType=TINYINT},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    tenant_id,
    project_id,
    env_id,
    ds_type,
    conn_name,
    conn_host,
    conn_port,
    conn_database,
    conn_username,
    conn_password,
    advanced_config,
    memo,
    created_by,
    created_time,
    updated_by,
    updated_time,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.envId, jdbcType=VARCHAR},
    #{item.dsType, jdbcType=TINYINT},
    #{item.connName, jdbcType=VARCHAR},
    #{item.connHost, jdbcType=VARCHAR},
    #{item.connPort, jdbcType=INTEGER},
    #{item.connDatabase, jdbcType=VARCHAR},
    #{item.connUsername, jdbcType=VARCHAR},
    #{item.connPassword, jdbcType=VARCHAR},
    #{item.advancedConfig, jdbcType=VARCHAR},
    #{item.memo, jdbcType=VARCHAR},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.project.db.entity.CpProjectEnvDs">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="envId != null">
        env_id = #{envId, jdbcType=VARCHAR},
      </if>
      <if test="dsType != null">
        ds_type = #{dsType, jdbcType=TINYINT},
      </if>
      <if test="connName != null">
        conn_name = #{connName, jdbcType=VARCHAR},
      </if>
      <if test="connHost != null">
        conn_host = #{connHost, jdbcType=VARCHAR},
      </if>
      <if test="connPort != null">
        conn_port = #{connPort, jdbcType=INTEGER},
      </if>
      <if test="connDatabase != null">
        conn_database = #{connDatabase, jdbcType=VARCHAR},
      </if>
      <if test="connUsername != null">
        conn_username = #{connUsername, jdbcType=VARCHAR},
      </if>
      <if test="connPassword != null">
        conn_password = #{connPassword, jdbcType=VARCHAR},
      </if>
      <if test="advancedConfig != null">
        advanced_config = #{advancedConfig, jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        memo = #{memo, jdbcType=VARCHAR},
      </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>
      <if test="deleted != null">
        is_deleted = #{deleted, jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.project.db.entity.CpProjectEnvDs">
    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="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="envId != null">
        AND env_id = #{envId,jdbcType=VARCHAR}
      </if>
      <if test="dsType != null">
        AND ds_type = #{dsType,jdbcType=TINYINT}
      </if>
      <if test="connName != null">
        AND conn_name = #{connName,jdbcType=VARCHAR}
      </if>
      <if test="connHost != null">
        AND conn_host = #{connHost,jdbcType=VARCHAR}
      </if>
      <if test="connPort != null">
        AND conn_port = #{connPort,jdbcType=INTEGER}
      </if>
      <if test="connDatabase != null">
        AND conn_database = #{connDatabase,jdbcType=VARCHAR}
      </if>
      <if test="connUsername != null">
        AND conn_username = #{connUsername,jdbcType=VARCHAR}
      </if>
      <if test="connPassword != null">
        AND conn_password = #{connPassword,jdbcType=VARCHAR}
      </if>
      <if test="advancedConfig != null">
        AND advanced_config = #{advancedConfig,jdbcType=VARCHAR}
      </if>
      <if test="memo != null">
        AND memo = #{memo,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="deleted != null">
        AND is_deleted = #{deleted,jdbcType=TINYINT}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.project.db.entity.CpProjectEnvDs">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="envId != null">
        AND env_id=#{envId,jdbcType=VARCHAR}
      </if>
      <if test="dsType != null">
        AND ds_type=#{dsType,jdbcType=TINYINT}
      </if>
      <if test="connName != null">
        AND conn_name=#{connName,jdbcType=VARCHAR}
      </if>
      <if test="connHost != null">
        AND conn_host=#{connHost,jdbcType=VARCHAR}
      </if>
      <if test="connPort != null">
        AND conn_port=#{connPort,jdbcType=INTEGER}
      </if>
      <if test="connDatabase != null">
        AND conn_database=#{connDatabase,jdbcType=VARCHAR}
      </if>
      <if test="connUsername != null">
        AND conn_username=#{connUsername,jdbcType=VARCHAR}
      </if>
      <if test="connPassword != null">
        AND conn_password=#{connPassword,jdbcType=VARCHAR}
      </if>
      <if test="advancedConfig != null">
        AND advanced_config=#{advancedConfig,jdbcType=VARCHAR}
      </if>
      <if test="memo != null">
        AND memo=#{memo,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="deleted != null">
        AND is_deleted=#{deleted,jdbcType=TINYINT}
      </if>
    </trim>
  </select>

</mapper>