From 016e47ea961d84a186db0bbd45cd6d7eaaa57bc3 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Fri, 26 Jan 2024 16:30:20 +0800
Subject: [PATCH] 文章添加小区id 字段

---
 src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml |   56 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 12 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 ea9370a..b22f708 100644
--- a/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
@@ -105,21 +105,32 @@
     <!--根据父编号查询所有的下级-->
     <select id="getTreeList" resultType="org.springblade.common.node.TreeStringNode">
         <if test="region.cityCode!=null and region.cityCode!=''">
-            SELECT
-            code as id,
-            parent_code as parentId,
-            name
-            FROM blade_region
-            where code = #{region.cityCode}
-            union all
+        SELECT
+        code as id,
+        parent_code as parentId,
+        name,
+        sort
+        FROM blade_region
+        where code = #{region.cityCode}
+        union all
+        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 br.city_code = #{region.cityCode}
+        union all
         </if>
         SELECT
         code as id,
         parent_code as parentId,
-        name
+        name,
+        sort
         FROM blade_region
         where 1=1
-        and district_code = '361102000000'
+        and district_code = '361102'
         <if test="region.parentCode!=null and region.parentCode!=''">
             and parent_code = #{region.parentCode}
         </if>
@@ -132,7 +143,7 @@
                     </foreach>
                 </when>
                 <otherwise>
-                    and code in ('')
+                    and 1=1
                 </otherwise>
             </choose>
         </if>
@@ -144,7 +155,7 @@
         code as id,
         parent_code as parentId,
         name
-        FROM blade_region where district_code = '361102000000'
+        FROM blade_region where district_code = '361102'
         and region_level = 4
         <if test="regionCode!=null  and regionCode!=''">
             and code = #{regionCode}
@@ -154,7 +165,7 @@
         code as id,
         parent_code as parentId,
         name
-        FROM blade_region where district_code = '361102000000'
+        FROM blade_region where district_code = '361102'
         and region_level = 4
         <if test="regionCode!=null  and regionCode!=''">
             and parent_code = #{regionCode}
@@ -177,4 +188,25 @@
         where length(parent_code) &lt; 12
     </select>
 
+    <!--查询下级区域(拼接网格)-->
+    <select id="getRegionChildList" resultType="org.springblade.modules.system.entity.Region">
+        SELECT
+        code,parent_code,name,ancestors,region_level,sort
+        FROM blade_region
+        where ancestors like concat('%',#{regionCode},'%')
+        union all
+        (
+        SELECT
+        jg.grid_code as code,
+        jg.community_code as parent_code,
+        jg.grid_name as name,
+        '' as ancestors,
+        6 as region_level,
+        jg.sort
+        FROM blade_region br
+        right join jczz_grid jg on jg.community_code = br.village_code and jg.is_deleted = 0
+        where br.ancestors like concat('%',#{regionCode},'%')
+        )
+    </select>
+
 </mapper>

--
Gitblit v1.9.3