From a179a45ac39a1cf87c611c56fe80c8648aed639a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 21 一月 2022 18:41:41 +0800 Subject: [PATCH] 优化通道选择是通道的查询 --- src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java index 03c66d4..59ecdbc 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java @@ -24,7 +24,9 @@ @Delete("DELETE FROM platform_catalog WHERE platformId=#{platformId}") int delByPlatformId(String platformId); - @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id AND platformId=#{platformId}) as childrenCount FROM platform_catalog pc WHERE parentId=#{parentId} AND platformId=#{platformId}") + @Select("SELECT pc.*, count(pc2.id) as childrenCount FROM platform_catalog pc " + + "left join platform_catalog pc2 on pc.id = pc2.parentId " + + "WHERE pc.parentId=#{parentId} AND pc.platformId=#{platformId} group by pc.id") List<PlatformCatalog> selectByParentId(String platformId, String parentId); @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.id=#{id}") -- Gitblit v1.8.0