From 258825f9bae5492e8d0726d33b75e00417090f72 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 23 七月 2023 19:46:33 +0800 Subject: [PATCH] 修改?ak=参数 --- src/main/java/com/moon/server/service/sys/ProxyService.java | 2 +- src/main/resources/application.yml | 8 +++++--- src/main/java/com/moon/server/helper/HttpHelper.java | 19 ++++++++++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/moon/server/helper/HttpHelper.java b/src/main/java/com/moon/server/helper/HttpHelper.java index 635cd78..1900668 100644 --- a/src/main/java/com/moon/server/helper/HttpHelper.java +++ b/src/main/java/com/moon/server/helper/HttpHelper.java @@ -20,7 +20,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.io.OutputStream; import java.net.HttpCookie; import java.net.URI; import java.net.URISyntaxException; @@ -294,7 +293,7 @@ } private String filterStr(HttpServletRequest request, HttpServletResponse response, ResEntity res, String str) { - String url = res.getUrl(); + /*String url = res.getUrl(); if (url.contains(StaticData.AK)) { String[] strs = url.split("\\?"); url = strs[0]; @@ -308,11 +307,25 @@ proxyUrl = request.getRequestURL().substring(0, request.getRequestURL().indexOf(proxyUrl) + proxyUrl.length()); str = str.replace(url, proxyUrl); - if (str.contains(StaticData.REST_LAYER)) { + if (StaticData.THREE == res.getFirm() && str.contains(StaticData.REST_LAYER)) { str = str.replace(url.replace("/wmts/layer/", StaticData.REST_LAYER), proxyUrl); } } + return str;*/ + + String[] strs = res.getUrl().contains(StaticData.AK) ? res.getUrl().split("\\?") : new String[]{res.getUrl(), null}; + if (str.contains(strs[0])) { + String proxyUrl = res.getProxy().replace("{token}", response.getHeader("token")); + proxyUrl = request.getRequestURL().substring(0, request.getRequestURL().indexOf(proxyUrl) + proxyUrl.length()); + str = str.replace(strs[0], proxyUrl); + + if (StaticData.THREE == res.getFirm() && str.contains(StaticData.REST_LAYER)) { + + + } + } + return str; } } 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 1b03132..62ad985 100644 --- a/src/main/java/com/moon/server/service/sys/ProxyService.java +++ b/src/main/java/com/moon/server/service/sys/ProxyService.java @@ -56,7 +56,7 @@ // 9.鑾峰彇璧勬簮瀹炰綋 ResEntity entity = getResEntity(ue, resId); - if (null == entity || entity.getType() != StaticData.THREE || StringHelper.isNull(entity.getProxy()) || StringHelper.isNull(entity.getUrl())) { + if (null == entity || StaticData.THREE != entity.getType() || StringHelper.isNull(entity.getProxy()) || StringHelper.isNull(entity.getUrl())) { WebHelper.writeStr2Page(res, ILLEGAL_RESOURCE); return; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index cba0b59..c121a8b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,7 +12,7 @@ # redis redis: database: 0 - host: 192.168.20.83 + host: 127.0.0.1 port: 6369 password: rediS_5L#F4_Server timeout: 10000 # 杩炴帴瓒呮椂鏃堕暱锛堟绉掞級 @@ -42,9 +42,11 @@ datasource: name: prod # JDBC 鍩烘湰閰嶇疆 ¤tSchema=public - url: jdbc:postgresql://192.168.20.83:5433/moon?useAffectedRows=true + #url: jdbc:postgresql://192.168.20.83:5433/moon?useAffectedRows=true + url: jdbc:postgresql://127.0.0.1:5433/moon?useAffectedRows=true username : postgres - password: Postgres!_14_moon + #password: Postgres!_14_moon + password: postgres driver-class-name: org.postgresql.Driver platform: POSTGRESQL type: com.alibaba.druid.pool.DruidDataSource -- Gitblit v1.9.3