TenantMapper.xml
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?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>