소스 검색

修改dispatch路径

fengyanjie 3 년 전
부모
커밋
540eee8de6

+ 14 - 9
iot-admin/src/main/java/com/persagy/dmp/admin/controller/DmpGatewayController.java

@@ -5,6 +5,7 @@ import com.persagy.common.web.MapResponse;
 import com.persagy.common.web.ServletUtils;
 import com.persagy.dmp.common.http.HttpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,27 +27,31 @@ public class DmpGatewayController {
     @Autowired
     private HttpUtils httpUtils;
 
-    @PostMapping("/report/**")
-    public void report(HttpServletRequest request, HttpServletResponse response, @RequestBody JsonNode param) {
-        dispatch(request, response, param);
-    }
+    @Value("${dispatch.dic}")
+    private String dicUrl;
+
+    @Value("${dispatch.org}")
+    private String orgUrl;
+
+    @Value("${dispatch.rwd}")
+    private String rwdUrl;
 
     @PostMapping("/dic/**")
     public void dic(HttpServletRequest request, HttpServletResponse response, @RequestBody JsonNode param) {
-        dispatch(request, response, param);
+        dispatch(request, response, param, dicUrl);
     }
 
     @PostMapping("/org/**")
     public void org(HttpServletRequest request, HttpServletResponse response, @RequestBody JsonNode param) {
-        dispatch(request, response, param);
+        dispatch(request, response, param, orgUrl);
     }
 
     @PostMapping("/rwd/**")
     public void rwd(HttpServletRequest request, HttpServletResponse response, @RequestBody JsonNode param) {
-        dispatch(request, response, param);
+        dispatch(request, response, param, rwdUrl);
     }
 
-    private void dispatch(HttpServletRequest request, HttpServletResponse response, @RequestBody JsonNode param) {
+    private void dispatch(HttpServletRequest request, HttpServletResponse response, @RequestBody JsonNode param, String dispatchUrl) {
         Map<String, String[]> parameterMap = request.getParameterMap();
         String[] dmpServers = parameterMap.get("dmpServer");
         if (dmpServers == null) {
@@ -56,7 +61,7 @@ public class DmpGatewayController {
             return;
         }
         StringBuilder url = new StringBuilder("http://" + dmpServers[0]);
-        String uri = request.getRequestURI().replace("/admin/dmp", "");
+        String uri = request.getRequestURI().replace("/admin/dmp", dispatchUrl);
         url.append(uri);
         String queryString = request.getQueryString();
         if (!"/rwd/def/class".equalsIgnoreCase(uri) && !"/rwd/def/funcid".equalsIgnoreCase(uri)) {

+ 5 - 1
iot-admin/src/main/resources/application-aliyun-test.yml

@@ -2,4 +2,8 @@ server:
   port: 8080
 spring:
   application:
-    name: iot-admin
+    name: iot-admin
+dispatch:
+  org: dmp-org
+  rwd: dmp-rwd
+  dic: dmp-dic

+ 5 - 1
iot-admin/src/main/resources/application-dev.yml

@@ -1,2 +1,6 @@
 server:
-  port: 8080
+  port: 8080
+dispatch:
+  org: dmp-org
+  rwd: dmp-rwd
+  dic: dmp-dic

+ 5 - 1
iot-admin/src/main/resources/application-test.yml

@@ -2,4 +2,8 @@ server:
   port: 8080
 spring:
   application:
-    name: iot-admin
+    name: iot-admin
+dispatch:
+  org: dmp-org
+  rwd: dmp-rwd
+  dic: dmp-dic

+ 5 - 1
iot-admin/src/main/resources/application.yml

@@ -5,4 +5,8 @@ spring:
     name: iot-admin
   profiles:
     active:
-    - dev,log-dev
+    - dev,log-dev
+dispatch:
+  org: /dmp-org
+  rwd: /dmp-rwd
+  dic: /dmp-dic