From 2b599a5307883b9407ea9225c4e33fc28706f7a8 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Tue, 30 Apr 2024 09:49:37 +0800
Subject: [PATCH] 新增社区树查询接口(单独)

---
 src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml |   44 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml b/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
index da5f846..a36c2e5 100644
--- a/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
@@ -152,14 +152,14 @@
     <!--根据父编号查询所有的下级-->
     <select id="getTreeList" resultType="org.springblade.common.node.TreeStringNode">
         <if test="region.cityCode!=null and region.cityCode!=''">
-        select
-        grid_code as id,
-        community_code as parentId,
-        grid_name as name,
-        jg.sort
-        FROM jczz_grid jg
-        left join blade_region br on br.village_code = jg.community_code and br.region_level = 5
-        where jg.is_deleted = 0 and jg.community_code like concat(#{region.cityCode},'%')
+            select
+            grid_code as id,
+            community_code as parentId,
+            grid_name as name,
+            jg.sort
+            FROM jczz_grid jg
+            left join blade_region br on br.village_code = jg.community_code and br.region_level = 5
+            where jg.is_deleted = 0 and jg.community_code like concat(#{region.cityCode},'%')
             <if test="isAdministrator==2">
                 <choose>
                     <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
@@ -173,7 +173,7 @@
                     </otherwise>
                 </choose>
             </if>
-        union all
+            union all
         </if>
         SELECT
         code as id,
@@ -337,4 +337,30 @@
         )
     </select>
 
+
+    <!--根据父编号查询所有的下级-->
+    <select id="treeToCommunity" resultType="org.springblade.common.node.TreeStringNode">
+        select
+        br.code as id,
+        br.parent_code as parentId,
+        br.name as name,
+        br.sort
+        FROM blade_region br
+        left join jczz_grid jg on br.village_code = jg.community_code and jg.is_deleted = 0 and br.region_level = 5
+        where 1=1 and (br.ancestors like '%361102%' or br.code = '361102')
+        <if test="isAdministrator==2">
+            <choose>
+                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                    and jg.community_code in
+                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                        #{code}
+                    </foreach>
+                </when>
+                <otherwise>
+                    and jg.community_code in ('')
+                </otherwise>
+            </choose>
+        </if>
+    </select>
+
 </mapper>

--
Gitblit v1.9.3