TenantMapper.xml 1.94 KB
<?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">

<mapper namespace="org.thingsboard.server.dao.yunteng.mapper.TenantMapper">
    <resultMap type="org.thingsboard.server.common.data.yunteng.dto.TenantDTO" id="tenantDTOMap">
        <result property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="name" column="name"/>
        <result property="enabled" column="enabled"/>
        <result property="description" column="description"/>
        <result property="defaultConfig" column="default_config"/>
        <result property="tenantExpireTime" column="tenant_expire_time"/>
        <result property="createTime" column="create_time"/>
        <result property="icon" column="icon"/>
        <result property="tenantProfileId" column="tenant_profile_id"/>
    </resultMap>

    <sql id="column">
        id
                , tenant_id,name, enabled, description, default_config, tenant_expire_time, create_time,icon,tenant_profile_id
    </sql>
    <select id="getTenantIdsByTenantIds" resultType="java.lang.String">
        SELECT tenant_id FROM sys_tenant WHERE id IN
        <foreach collection="tenantIds" item="tenantId" open="(" separator="," close=")">
            #{tenantId}
        </foreach>
    </select>

    <select id="getTenantPage" resultMap="tenantDTOMap">
        SELECT
        <include refid="column"/>
        FROM sys_tenant
        <where>
            tenant_id != #{defaultTenantId}
            <if test="tenantName!=null">
                AND name LIKE CONCAT('%',#{tenantName}::TEXT,'%')
            </if>
        </where>
    </select>

    <select id="getCurrentMonthExpireTenantPage" resultMap="tenantDTOMap">
        SELECT
        <include refid="column"/>
        FROM sys_tenant WHERE to_char(tenant_expire_time,'yyyy-mm') = to_char((SELECT now() as timestamp),'yyyy-mm')
    </select>
</mapper>