From f711133a8d1e8f00ce6beb026b6f54731533ecc1 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 27 九月 2023 17:59:07 +0800
Subject: [PATCH] 修改代理服务-4

---
 src/main/java/com/moon/server/entity/all/StaticData.java    |    6 ++++++
 src/main/java/com/moon/server/service/sys/ProxyService.java |    2 ++
 src/main/java/com/moon/server/helper/HttpHelper.java        |   24 +++++++++++++++++++++---
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/moon/server/entity/all/StaticData.java b/src/main/java/com/moon/server/entity/all/StaticData.java
index a424a62..8da63e7 100644
--- a/src/main/java/com/moon/server/entity/all/StaticData.java
+++ b/src/main/java/com/moon/server/entity/all/StaticData.java
@@ -28,6 +28,10 @@
 
     public final static int I5 = 5;
 
+    public final static int I6 = 6;
+
+    public final static int I8 = 8;
+
     public final static int NINE = 9;
 
     public final static int TEN = 10;
@@ -196,6 +200,8 @@
 
     public final static String COMPOUNDCURVE = "COMPOUNDCURVE";
 
+    public final static String QUERYABLE = "<Layer queryable=\"1\" opaque=\"0\">";
+
     public static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "鏂囦欢鎵句笉鍒�"));
 
     /**
diff --git a/src/main/java/com/moon/server/helper/HttpHelper.java b/src/main/java/com/moon/server/helper/HttpHelper.java
index 19d8eff..3b37fbf 100644
--- a/src/main/java/com/moon/server/helper/HttpHelper.java
+++ b/src/main/java/com/moon/server/helper/HttpHelper.java
@@ -286,11 +286,29 @@
     }
 
     private void copeGeoService(HttpResponse proxyResponse, HttpServletRequest request, HttpServletResponse response, ResEntity res) throws IOException {
-        if (StaticData.GET_CAPABILITIES.equals(res.getBak())) {
-            //
+        if (!StaticData.GET_CAPABILITIES.equals(res.getBak())) {
+            proxyResponse.getEntity().writeTo(response.getOutputStream());
+            return;
         }
 
-        proxyResponse.getEntity().writeTo(response.getOutputStream());
+        String str = EntityUtils.toString(proxyResponse.getEntity(), "UTF-8");
+        int index = str.indexOf(StaticData.QUERYABLE);
+        while (index > -1) {
+            int start = str.indexOf("<Name>", index) + StaticData.I6;
+            int end = str.indexOf("</Layer>", index) + StaticData.I8;
+
+            String name = ":" + str.substring(start, str.indexOf("</Name>", start));
+            if (!res.getTab().contains(name)) {
+                str = str.substring(0, index) + str.substring(end);
+                index = str.indexOf(StaticData.QUERYABLE, index);
+            } else {
+                index = str.indexOf(StaticData.QUERYABLE, end);
+            }
+        }
+
+        byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
+        response.setContentLength(bytes.length);
+        response.getOutputStream().write(bytes);
     }
 
     private void copeSjService(HttpResponse proxyResponse, HttpServletRequest request, HttpServletResponse response, ResEntity res) throws IOException {
diff --git a/src/main/java/com/moon/server/service/sys/ProxyService.java b/src/main/java/com/moon/server/service/sys/ProxyService.java
index 5624a36..029c420 100644
--- a/src/main/java/com/moon/server/service/sys/ProxyService.java
+++ b/src/main/java/com/moon/server/service/sys/ProxyService.java
@@ -253,6 +253,8 @@
 
             str = str.replace(str.substring(start, end > -1 ? end : str.length()), "layers=" + layers);
         } else {
+            List<String> tabs = StaticData.ADMIN.equals(ue.getUid()) ? permsService.selectAllTabs() : permsService.selectTabs(ue.getUid());
+            entity.setTab(null == tabs ? "" : StringHelper.join(tabs, ","));
             entity.setBak(StaticData.GET_CAPABILITIES);
         }
 

--
Gitblit v1.9.3