From 2e9ac6878d3d7a59c200be7d74811c89dadf3a44 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期六, 06 一月 2024 10:22:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
index dbec7d5..8a41586 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
@@ -1,5 +1,8 @@
 package com.dy.pipIrrBase.district;
 
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
 import com.dy.common.aop.SsoAop;
 import com.dy.common.mybatis.envm.Deleted;
 import com.dy.common.webUtil.BaseResponse;
@@ -263,4 +266,52 @@
         }
         return BaseResponseUtils.buildSuccess(map_Districts);
     }
+
+    /**
+     * 鑾峰彇涓夌骇琛屾斂鍖哄垝
+     * @return 鍘块晣鏉戜笁绾ц鏀垮尯鍒�
+     */
+    @GetMapping(path = "/three")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getThreeDistrict() {
+        JSONArray array_counties = new JSONArray();
+        JSONArray array_towns = new JSONArray();
+        JSONArray array_villages = new JSONArray();
+
+        List<Map<String, Object>> list_counties = Optional.ofNullable(sv.getDistrictgsByLevel(2)).orElse(new ArrayList<>());
+        if(list_counties.size() > 0) {
+            array_counties = JSONArray.parseArray(JSON.toJSONString(list_counties));
+            // 閬嶅巻姣忎竴涓幙锛屽皢鍘夸笅鐨勯晣鏉戝姞鍒板幙鐨勫瓙闆�
+            for(int i = 0; i < array_counties.size(); i++) {
+                JSONObject job_county = array_counties.getJSONObject(i);
+                    Long countyId = job_county.getLong("id");
+                    List<Map<String, Object>> list_towns = Optional.ofNullable(sv.getDistrictsBySupperId(countyId)).orElse(new ArrayList<>());
+                    if(list_towns.size() > 0) {
+                        array_towns = JSONArray.parseArray(JSON.toJSONString(list_towns));
+                        // 閬嶅巻姣忎竴涓晣锛屽皢闀囦笅鏉戝垪琛ㄥ姞鍒伴晣鐨勫瓙闆�
+                        for(int j = 0; j < array_towns.size(); j++) {
+                            JSONObject job_town = array_towns.getJSONObject(j);
+                            Long townId = job_town.getLong("id");
+                            List<Map<String, Object>> list_villages = Optional.ofNullable(sv.getDistrictsBySupperId(townId)).orElse(new ArrayList<>());
+                            if(list_villages.size() > 0) {
+                                array_villages = JSONArray.parseArray(JSON.toJSONString(list_villages));
+                                job_town.put("children", array_villages);
+                            }
+                        }
+                        //System.out.println("----" + array_towns);
+                    }
+                    // 闀囨潙缁勮瀹屾瘯锛屽皢闀囨潙鍔犲埌鍘夸笅
+                    job_county.put("children", array_towns);
+            }
+            // 鍘跨粍瑁呭畬姣�
+            //String a = array_counties.toJSONString();
+            //System.out.println(a);
+            return BaseResponseUtils.buildSuccess(array_counties);
+        }else {
+            return BaseResponseUtils.buildFail("鍘跨骇琛屾斂鍖哄垝涓嶅瓨鍦�");
+        }
+
+
+        //return BaseResponseUtils.buildSuccess();
+    }
 }

--
Gitblit v1.8.0