mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 08:55:53 +08:00
多租户的测试调整
This commit is contained in:
@@ -54,12 +54,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where log_id = #{logId}
|
||||
</select>
|
||||
|
||||
<select id="selectCategoryLogCount" parameterType="Long" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||
<select id="selectCategoryLogCount" parameterType="com.ruoyi.iot.domain.Device" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||
SELECT
|
||||
(select count(log_id) from iot_device_log where log_type=1) as propertyCount,
|
||||
(select count(log_id) from iot_device_log where log_type=2) as functionCount,
|
||||
(select count(log_id) from iot_device_log where log_type=3) as eventCount,
|
||||
(select count(log_id) from iot_device_log where log_type=1 and is_monitor=1) as monitorCount
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=1</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as propertyCount,
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=2</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as functionCount,
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=3</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as eventCount,
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=1 and is_monitor=1</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as monitorCount
|
||||
from iot_device_log
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
@@ -214,11 +214,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where device_id = #{deviceId}
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceProductAlertCount" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||
<select id="selectDeviceProductAlertCount" parameterType="com.ruoyi.iot.domain.Device" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||
SELECT count(device_id) as deviceCount,
|
||||
(select count(product_id) from iot_product) as productCount,
|
||||
(select count(alert_log_id) from iot_alert_log) as alertCount
|
||||
(
|
||||
<!--普通用户查询设备中的产品数量-->
|
||||
<if test="userId != null and userId != 0">
|
||||
select count(product_id)
|
||||
from iot_device
|
||||
where user_id = #{userId}
|
||||
group by product_id
|
||||
</if>
|
||||
<!--管理员和租户直接查询产品的数量-->
|
||||
<if test="userId == null || userId == 0">
|
||||
select count(product_id)
|
||||
from iot_product
|
||||
<where>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId} </if>
|
||||
</where>
|
||||
</if>
|
||||
) as productCount,
|
||||
(select count(alert_log_id)
|
||||
from iot_alert_log
|
||||
<where>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as alertCount
|
||||
from iot_device
|
||||
<where>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectProductAuthenticate" parameterType="com.ruoyi.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
|
||||
|
||||
@@ -78,10 +78,38 @@
|
||||
|
||||
<select id="selectCategoryLogCount" parameterType="Long" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||
SELECT
|
||||
(select count(log_id) from iot_device_log where log_type=1) as propertyCount,
|
||||
(select count(log_id) from iot_device_log where log_type=2) as functionCount,
|
||||
(select count(log_id) from iot_device_log where log_type=3) as eventCount,
|
||||
(select count(log_id) from iot_device_log where log_type=1 and is_monitor=1) as monitorCount
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=1</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as propertyCount,
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=2</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as functionCount,
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=3</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as eventCount,
|
||||
(select count(log_id)
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=1 and is_monitor=1</if>
|
||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as monitorCount
|
||||
from ${database}.device_log
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user