You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
5.0 KiB
135 lines
5.0 KiB
|
7 months ago
|
<?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="com.techsor.datacenter.business.dao.ex.BasicTenantMapperExt">
|
||
|
|
|
||
|
|
<select id="checkExist" resultType="java.util.Map">
|
||
|
|
SELECT 1 AS exist_flag
|
||
|
|
FROM basic_tenant
|
||
|
|
WHERE flag != 1
|
||
|
|
AND (
|
||
|
|
<if test="tenantUdfId != null">
|
||
|
|
tenant_udf_id = #{tenantUdfId}
|
||
|
|
</if>
|
||
|
|
)
|
||
|
|
LIMIT 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="checkOtherExist" resultType="java.util.Map">
|
||
|
|
SELECT 1 AS exist_flag
|
||
|
|
FROM basic_tenant
|
||
|
|
WHERE flag != 1
|
||
|
|
|
||
|
|
<if test="tenantUdfId != null">
|
||
|
|
AND tenant_udf_id = #{tenantUdfId}
|
||
|
|
</if>
|
||
|
|
<if test="tenantId != null">
|
||
|
|
AND tenant_id != #{tenantId}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
LIMIT 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="checkSpaceIdUsed" resultType="java.util.Map">
|
||
|
|
SELECT 1 AS exist_flag
|
||
|
|
FROM basic_tenant
|
||
|
|
WHERE flag != 1
|
||
|
|
AND tenant_id != #{tenantId}
|
||
|
|
<!-- AND (-->
|
||
|
|
<!-- <if test="spaceId != null">-->
|
||
|
|
<!-- FIND_IN_SET(#{spaceId}, basic_tenant.r_space_ids)-->
|
||
|
|
<!-- </if>-->
|
||
|
|
<!-- )-->
|
||
|
|
LIMIT 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getListPage" resultType="com.techsor.datacenter.business.vo.tenant.TenantPageVO">
|
||
|
|
SELECT
|
||
|
|
basic_tenant.tenant_id AS tenantId,
|
||
|
|
basic_tenant.tenant_udf_id AS tenantUdfId,
|
||
|
|
basic_tenant.tenant_name AS tenantName,
|
||
|
|
<!-- basic_tenant.r_space_ids AS rSpaceIds,-->
|
||
|
|
basic_tenant.building_id AS buildingId
|
||
|
|
FROM basic_tenant
|
||
|
|
WHERE flag != 1
|
||
|
|
<if test="tenantUdfId != null and tenantUdfId != ''">
|
||
|
|
AND basic_tenant.tenant_udf_id = #{tenantUdfId}
|
||
|
|
</if>
|
||
|
|
<if test="buildingId != null and buildingId != ''">
|
||
|
|
AND basic_tenant.building_id = #{buildingId}
|
||
|
|
</if>
|
||
|
|
<if test="spaceId != null and spaceId != ''">
|
||
|
|
AND FIND_IN_SET(#{spaceId}, basic_tenant.r_space_ids)
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getAll" resultType="com.techsor.datacenter.business.vo.tenant.TenantPageVO">
|
||
|
|
SELECT
|
||
|
|
basic_tenant.tenant_id AS tenantId,
|
||
|
|
basic_tenant.tenant_udf_id AS tenantUdfId,
|
||
|
|
basic_tenant.tenant_name AS tenantName,
|
||
|
|
<!-- basic_tenant.r_space_ids AS rSpaceIds,-->
|
||
|
|
basic_tenant.building_id AS buildingId
|
||
|
|
FROM basic_tenant
|
||
|
|
WHERE flag != 1
|
||
|
|
AND basic_tenant.company_id= #{companyId}
|
||
|
|
<if test="buildingId != null and buildingId != ''">
|
||
|
|
AND basic_tenant.building_id = #{buildingId}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="downloadTenant" resultType="com.techsor.datacenter.business.vo.tenant.TenantDownloadVO">
|
||
|
|
SELECT
|
||
|
|
bb.name as buildingName,
|
||
|
|
bt.tenant_udf_id AS tenantUdfId,
|
||
|
|
bt.tenant_name AS tenantName,
|
||
|
|
bb.name AS buildingName
|
||
|
|
FROM basic_tenant bt
|
||
|
|
LEFT JOIN basic_building bb ON bb.building_id = bt.building_id
|
||
|
|
WHERE bt.flag != 1
|
||
|
|
<if test="tenantUdfId != null and tenantUdfId != ''">
|
||
|
|
AND bt.tenant_udf_id = #{tenantUdfId}
|
||
|
|
</if>
|
||
|
|
<if test="buildingId != null and buildingId != ''">
|
||
|
|
AND bt.building_id = #{buildingId}
|
||
|
|
</if>
|
||
|
|
GROUP BY bt.tenant_udf_id, bt.tenant_name, bb.name;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getOtherTenantAndSpaceList" resultType="com.techsor.datacenter.business.vo.tenant.TenantDownloadVO">
|
||
|
|
SELECT
|
||
|
|
bb.name as buildingName,
|
||
|
|
bt.tenant_udf_id AS tenantUdfId,
|
||
|
|
bt.tenant_name AS tenantName,
|
||
|
|
bb.name AS buildingName,
|
||
|
|
GROUP_CONCAT(bs.name SEPARATOR ',') AS relatedSpaceNames
|
||
|
|
FROM basic_tenant bt
|
||
|
|
LEFT JOIN basic_building bb ON bb.building_id = bt.building_id
|
||
|
|
<!-- LEFT JOIN basic_space bs ON FIND_IN_SET(bs.space_id, bt.r_space_ids) > 0-->
|
||
|
|
WHERE bt.flag != 1
|
||
|
|
<!-- <if test="tenantUdfIdList != null and tenantUdfIdList.size() > 0">-->
|
||
|
|
<!-- AND bt.tenant_udf_id NOT IN-->
|
||
|
|
<!-- <foreach item="item" index="index" collection="tenantUdfIdList" separator="," open="(" close=")">-->
|
||
|
|
<!-- #{item}-->
|
||
|
|
<!-- </foreach>-->
|
||
|
|
<!-- </if>-->
|
||
|
|
GROUP BY bt.tenant_udf_id, bt.tenant_name, bb.name;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="batchInsert" parameterType="java.util.List">
|
||
|
|
INSERT INTO basic_tenant (tenant_udf_id, tenant_name, building_id, company_id, creator_id, modifier_id,create_time, modify_time, flag)
|
||
|
|
VALUES
|
||
|
|
<foreach collection="list" item="item" separator=",">
|
||
|
|
(
|
||
|
|
#{item.tenantUdfId,jdbcType=VARCHAR},
|
||
|
|
#{item.tenantName,jdbcType=VARCHAR},
|
||
|
|
#{item.buildingId,jdbcType=BIGINT},
|
||
|
|
#{item.companyId,jdbcType=BIGINT},
|
||
|
|
#{item.creatorId,jdbcType=BIGINT},
|
||
|
|
#{item.modifierId,jdbcType=BIGINT},
|
||
|
|
#{item.createTime,jdbcType=BIGINT},
|
||
|
|
#{item.modifyTime,jdbcType=BIGINT},
|
||
|
|
#{item.flag,jdbcType=INTEGER}
|
||
|
|
)
|
||
|
|
</foreach>
|
||
|
|
</insert>
|
||
|
|
</mapper>
|