<?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 2021 . All rights reserved. -->
<!--  文件内容由代码生成器产生，请不要手动修改！ -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2021-04-22 14:34:18  -->
<mapper namespace="net.northking.cctp.saas.db.dao.SaasTenantDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.saas.db.entity.SaasTenant">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                      <!-- 租户代码 -->
    <result column="tenant_code" jdbcType="VARCHAR" property="tenantCode"/>
        <!-- 租户名称 -->
    <result column="tenant_name" jdbcType="VARCHAR" property="tenantName"/>
        <!-- 描述说明 -->
    <result column="memo" jdbcType="VARCHAR" property="memo"/>
        <!-- 负责人姓名 -->
    <result column="manager_name" jdbcType="VARCHAR" property="managerName"/>
        <!-- 负责人电话 -->
    <result column="manager_phone" jdbcType="VARCHAR" property="managerPhone"/>
        <!-- 负责人邮箱 -->
    <result column="manager_email" jdbcType="VARCHAR" property="managerEmail"/>
        <!-- 在线用户数量 -->
    <result column="max_online_user" jdbcType="INTEGER" property="maxOnlineUser"/>
        <!-- 数据隔离级别 -->
    <result column="isolation_level" jdbcType="VARCHAR" property="isolationLevel"/>
        <!-- 创建人 -->
    <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="BIT" property="deleted"/>
        <!-- 租户状态 -->
    <result column="tenant_status" jdbcType="VARCHAR" property="tenantStatus"/>
        <!-- 租户联系电话 -->
    <result column="tenant_phone" jdbcType="VARCHAR" property="tenantPhone"/>
        <!-- 租户邮箱 -->
    <result column="tenant_email" jdbcType="VARCHAR" property="tenantEmail"/>
        <!-- 租户类型 -->
    <result column="tenant_type" jdbcType="VARCHAR" property="tenantType"/>
        <!-- license数量 -->
    <result column="license_count" jdbcType="INTEGER" property="licenseCount"/>
        <!-- 启动/禁用 -->
    <result column="is_enable" jdbcType="BIT" property="enable"/>
        <!-- 租户结束时间 -->
    <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <!-- 是否展示二级菜单 -->
    <result column="position" jdbcType="BIT" property="position"/>
        <!-- 启动/禁用 -->
    <result column="project_space" jdbcType="BIT" property="projectSpace"/>
        <!-- 租户logoId-->
    <result column="logo_id" jdbcType="VARCHAR" property="logoId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tenant_code
    ,tenant_name
    ,memo
    ,manager_name
    ,manager_phone
    ,manager_email
    ,max_online_user
    ,isolation_level
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,is_deleted
    ,tenant_status
    ,tenant_phone
    ,tenant_email
    ,tenant_type
    ,license_count
    ,is_enable
    ,end_time
    ,position
    ,project_space
    ,logo_id
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.saas_tenant
  </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.saas.db.entity.SaasTenant">
    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="tenantCode != null">
          AND tenant_code=#{tenantCode,jdbcType=VARCHAR}
        </if>
              <if test="tenantName != null">
          AND tenant_name=#{tenantName,jdbcType=VARCHAR}
        </if>
              <if test="memo != null">
          AND memo=#{memo,jdbcType=VARCHAR}
        </if>
              <if test="managerName != null">
          AND manager_name=#{managerName,jdbcType=VARCHAR}
        </if>
              <if test="managerPhone != null">
          AND manager_phone=#{managerPhone,jdbcType=VARCHAR}
        </if>
              <if test="managerEmail != null">
          AND manager_email=#{managerEmail,jdbcType=VARCHAR}
        </if>
              <if test="maxOnlineUser != null">
          AND max_online_user=#{maxOnlineUser,jdbcType=INTEGER}
        </if>
              <if test="isolationLevel != null">
          AND isolation_level=#{isolationLevel,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=BIT}
        </if>
              <if test="tenantStatus != null">
          AND tenant_status=#{tenantStatus,jdbcType=VARCHAR}
        </if>
              <if test="tenantPhone != null">
          AND tenant_phone=#{tenantPhone,jdbcType=VARCHAR}
        </if>
              <if test="tenantEmail != null">
          AND tenant_email=#{tenantEmail,jdbcType=VARCHAR}
        </if>
              <if test="tenantType != null">
          AND tenant_type=#{tenantType,jdbcType=VARCHAR}
        </if>
              <if test="licenseCount != null">
          AND license_count=#{licenseCount,jdbcType=INTEGER}
        </if>
              <if test="enable != null">
          AND is_enable=#{enable,jdbcType=BIT}
        </if>
              <if test="endTime != null">
          AND end_time=#{endTime,jdbcType=TIMESTAMP}
        </if>
              <if test="position != null">
          AND position=#{position,jdbcType=BIT}
        </if>
              <if test="projectSpace != null">
          AND project_space=#{projectSpace,jdbcType=BIT}
        </if>
              <if test="logoId != null">
          AND logo_id=#{logoId,jdbcType=VARCHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.saas.db.entity.SaasTenant">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="tenantCode != null">
        tenant_code,
      </if>
      <if test="tenantName != null">
        tenant_name,
      </if>
      <if test="memo != null">
        memo,
      </if>
      <if test="managerName != null">
        manager_name,
      </if>
      <if test="managerPhone != null">
        manager_phone,
      </if>
      <if test="managerEmail != null">
        manager_email,
      </if>
      <if test="maxOnlineUser != null">
        max_online_user,
      </if>
      <if test="isolationLevel != null">
        isolation_level,
      </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>
      <if test="tenantStatus != null">
        tenant_status,
      </if>
      <if test="tenantPhone != null">
        tenant_phone,
      </if>
      <if test="tenantEmail != null">
        tenant_email,
      </if>
      <if test="tenantType != null">
        tenant_type,
      </if>
      <if test="licenseCount != null">
        license_count,
      </if>
      <if test="enable != null">
        is_enable,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="position != null">
        position,
      </if>
      <if test="projectSpace != null">
        project_space,
      </if>
      <if test="logoId != null">
        logo_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="tenantCode != null">
          #{tenantCode, jdbcType=VARCHAR},
      </if>
      <if test="tenantName != null">
          #{tenantName, jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
          #{memo, jdbcType=VARCHAR},
      </if>
      <if test="managerName != null">
          #{managerName, jdbcType=VARCHAR},
      </if>
      <if test="managerPhone != null">
          #{managerPhone, jdbcType=VARCHAR},
      </if>
      <if test="managerEmail != null">
          #{managerEmail, jdbcType=VARCHAR},
      </if>
      <if test="maxOnlineUser != null">
          #{maxOnlineUser, jdbcType=INTEGER},
      </if>
      <if test="isolationLevel != null">
          #{isolationLevel, 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=BIT},
      </if>
      <if test="tenantStatus != null">
          #{tenantStatus,jdbcType=VARCHAR},
      </if>
      <if test="tenantPhone != null">
          #{tenantPhone,jdbcType=VARCHAR},
      </if>
      <if test="tenantEmail != null">
          #{tenantEmail,jdbcType=VARCHAR},
      </if>
      <if test="tenantType != null">
          #{tenantType,jdbcType=VARCHAR},
      </if>
      <if test="licenseCount != null">
          #{licenseCount,jdbcType=INTEGER},
      </if>
      <if test="enable != null">
          #{enable,jdbcType=BIT},
      </if>
      <if test="endTime != null">
          #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="position != null">
        #{position,jdbcType=BIT},
      </if>
      <if test="projectSpace != null">
        #{projectSpace,jdbcType=BIT},
      </if>
      <if test="logoId != null">
        #{logoId, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    tenant_code,
    tenant_name,
    memo,
    manager_name,
    manager_phone,
    manager_email,
    max_online_user,
    isolation_level,
    created_by,
    created_time,
    updated_by,
    updated_time,
    is_deleted,
    tenant_status,
    tenant_phone,
    tenant_email,
    tenant_type,
    license_count,
    is_enable,
    end_time,
    position,
    project_space,
    logo_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.tenantCode, jdbcType=VARCHAR},
    #{item.tenantName, jdbcType=VARCHAR},
    #{item.memo, jdbcType=VARCHAR},
    #{item.managerName, jdbcType=VARCHAR},
    #{item.managerPhone, jdbcType=VARCHAR},
    #{item.managerEmail, jdbcType=VARCHAR},
    #{item.maxOnlineUser, jdbcType=INTEGER},
    #{item.isolationLevel, jdbcType=VARCHAR},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
    #{item.deleted, jdbcType=BIT},
    #{item.tenantStatus, jdbcType=VARCHAR},
    #{item.tenantPhone, jdbcType=VARCHAR},
    #{item.tenantEmail, jdbcType=VARCHAR},
    #{item.tenantType, jdbcType=VARCHAR},
    #{item.licenseCount, jdbcType=INTEGER},
    #{item.enable, jdbcType=BIT},
    #{item.endTime, jdbcType=TIMESTAMP},
    #{item.position,jdbcType=BIT},
    #{item.projectSpace,jdbcType=BIT},
    #{item.logoId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.saas.db.entity.SaasTenant">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="tenantCode != null">
        tenant_code = #{tenantCode, jdbcType=VARCHAR},
      </if>
      <if test="tenantName != null">
        tenant_name = #{tenantName, jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        memo = #{memo, jdbcType=VARCHAR},
      </if>
      <if test="managerName != null">
        manager_name = #{managerName, jdbcType=VARCHAR},
      </if>
      <if test="managerPhone != null">
        manager_phone = #{managerPhone, jdbcType=VARCHAR},
      </if>
      <if test="managerEmail != null">
        manager_email = #{managerEmail, jdbcType=VARCHAR},
      </if>
      <if test="maxOnlineUser != null">
        max_online_user = #{maxOnlineUser, jdbcType=INTEGER},
      </if>
      <if test="isolationLevel != null">
        isolation_level = #{isolationLevel, 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=BIT},
      </if>
      <if test="tenantStatus != null">
        tenant_status=#{tenantStatus,jdbcType=VARCHAR},
      </if>
      <if test="tenantPhone != null">
        tenant_phone=#{tenantPhone,jdbcType=VARCHAR},
      </if>
      <if test="tenantEmail != null">
        tenant_email=#{tenantEmail,jdbcType=VARCHAR},
      </if>
      <if test="tenantType != null">
        tenant_type=#{tenantType,jdbcType=VARCHAR},
      </if>
      <if test="licenseCount != null">
        license_count=#{licenseCount,jdbcType=INTEGER},
      </if>
      <if test="enable != null">
        is_enable=#{enable,jdbcType=BIT},
      </if>
      <if test="endTime != null">
        end_time = #{endTime, jdbcType=TIMESTAMP},
      </if>
      <if test="position != null">
        position=#{position,jdbcType=BIT},
      </if>
      <if test="projectSpace != null">
        project_space=#{projectSpace,jdbcType=BIT},
      </if>
      <if test="logoId != null">
        logo_id=#{logoId,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.saas.db.entity.SaasTenant">
    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="tenantCode != null">
        AND tenant_code = #{tenantCode,jdbcType=VARCHAR}
      </if>
      <if test="tenantName != null">
        AND tenant_name = #{tenantName,jdbcType=VARCHAR}
      </if>
      <if test="memo != null">
        AND memo = #{memo,jdbcType=VARCHAR}
      </if>
      <if test="managerName != null">
        AND manager_name = #{managerName,jdbcType=VARCHAR}
      </if>
      <if test="managerPhone != null">
        AND manager_phone = #{managerPhone,jdbcType=VARCHAR}
      </if>
      <if test="managerEmail != null">
        AND manager_email = #{managerEmail,jdbcType=VARCHAR}
      </if>
      <if test="maxOnlineUser != null">
        AND max_online_user = #{maxOnlineUser,jdbcType=INTEGER}
      </if>
      <if test="isolationLevel != null">
        AND isolation_level = #{isolationLevel,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=BIT}
      </if>
      <if test="tenantStatus != null">
        AND tenant_status=#{tenantStatus,jdbcType=VARCHAR}
      </if>
      <if test="tenantPhone != null">
        AND tenant_phone=#{tenantPhone,jdbcType=VARCHAR}
      </if>
      <if test="tenantEmail != null">
        AND tenant_email=#{tenantEmail,jdbcType=VARCHAR}
      </if>
      <if test="tenantType != null">
        AND tenant_type=#{tenantType,jdbcType=VARCHAR}
      </if>
      <if test="licenseCount != null">
        AND license_count=#{licenseCount,jdbcType=INTEGER}
      </if>
      <if test="enable != null">
        AND is_enable=#{enable,jdbcType=BIT}
      </if>
      <if test="endTime != null">
        AND end_time = #{endTime,jdbcType=TIMESTAMP}
      </if>
      <if test="position != null">
        AND position = #{position,jdbcType=BIT}
      </if>
      <if test="projectSpace != null">
        AND project_space = #{projectSpace,jdbcType=BIT}
      </if>
      <if test="logoId != null">
        AND logo_id=#{logoId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.saas.db.entity.SaasTenant">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="tenantCode != null">
        AND tenant_code=#{tenantCode,jdbcType=VARCHAR}
      </if>
      <if test="tenantName != null">
        AND tenant_name=#{tenantName,jdbcType=VARCHAR}
      </if>
      <if test="memo != null">
        AND memo=#{memo,jdbcType=VARCHAR}
      </if>
      <if test="managerName != null">
        AND manager_name=#{managerName,jdbcType=VARCHAR}
      </if>
      <if test="managerPhone != null">
        AND manager_phone=#{managerPhone,jdbcType=VARCHAR}
      </if>
      <if test="managerEmail != null">
        AND manager_email=#{managerEmail,jdbcType=VARCHAR}
      </if>
      <if test="maxOnlineUser != null">
        AND max_online_user=#{maxOnlineUser,jdbcType=INTEGER}
      </if>
      <if test="isolationLevel != null">
        AND isolation_level=#{isolationLevel,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=BIT}
      </if>
      <if test="tenantStatus != null">
        AND tenant_status=#{tenantStatus,jdbcType=VARCHAR}
      </if>
      <if test="tenantPhone != null">
        AND tenant_phone=#{tenantPhone,jdbcType=VARCHAR}
      </if>
      <if test="tenantEmail != null">
        AND tenant_email=#{tenantEmail,jdbcType=VARCHAR}
      </if>
      <if test="tenantType != null">
        AND tenant_type=#{tenantType,jdbcType=VARCHAR}
      </if>
      <if test="licenseCount != null">
        AND license_count=#{licenseCount,jdbcType=INTEGER}
      </if>
      <if test="enable != null">
        AND is_enable=#{enable,jdbcType=BIT}
      </if>
      <if test="endTime != null">
        AND end_time=#{endTime,jdbcType=TIMESTAMP}
      </if>
      <if test="position != null">
        AND position=#{position,jdbcType=BIT}
      </if>
      <if test="projectSpace != null">
        AND project_space=#{projectSpace,jdbcType=BIT}
      </if>
      <if test="logoId != null">
        AND logo_id=#{logoId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>