欧阳劲驰 преди 1 месец
родител
ревизия
5529f3e085

+ 7 - 1
custom-gateway-app/src/main/resources/application.yml

@@ -4,4 +4,10 @@ spring:
     name: KprCustomGateway
 #web
 server:
-  port: 9011
+  port: 9011
+  servlet:
+    context-path: /custom-gw/
+#网关
+gateway:
+  routes:
+    zydma: /zy-dma/

+ 3 - 3
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/config/RouterConfig.java

@@ -1,6 +1,6 @@
 package com.shkpr.service.customgateway.core.config;
 
-import com.shkpr.service.customgateway.core.properties.RouterProperties;
+import com.shkpr.service.customgateway.core.properties.GatewayProperties;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
 
@@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
  * @since 1.0.0
  */
 @Configuration
-@EnableConfigurationProperties(RouterProperties.class)
-public class RouterConfig {
+@EnableConfigurationProperties(GatewayProperties.class)
+public class GatewayConfig {
 
 }

+ 5 - 3
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/properties/RouterProperties.java

@@ -4,6 +4,8 @@ import lombok.Getter;
 import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
+import java.util.Map;
+
 /**
  * 路由属性
  *
@@ -12,10 +14,10 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
  */
 @Getter
 @Setter
-@ConfigurationProperties(prefix = "router")
-public class RouterProperties {
+@ConfigurationProperties(prefix = "gateway")
+public class GatewayProperties {
     /**
      * 路由集合
      */
-    String base;
+    private Map<String, String> routes;
 }

+ 0 - 24
custom-gateway-core/src/main/java/com/shkpr/service/customgateway/core/utils/NameUtils.java

@@ -1,24 +0,0 @@
-package com.shkpr.service.customgateway.core.utils;
-
-/**
- * 名称工具
- *
- * @author 欧阳劲驰
- * @since 1.0.0
- */
-public class NameUtils {
-    /**
-     * 前缀
-     */
-    public static final String GENERATED_NAME_PREFIX = "_gen_key_";
-
-    /**
-     * 生成名称
-     *
-     * @param i 序号
-     * @return 名称
-     */
-    public static String generateName(int i) {
-        return GENERATED_NAME_PREFIX + i;
-    }
-}

+ 0 - 2
custom-gateway-core/src/main/resources/application.yml

@@ -1,2 +0,0 @@
-router:
-  base: custom-gw

+ 15 - 0
custom-gateway-zydma/src/main/java/com/shkpr/service/customgateway/zydma/controller/TeatController.java

@@ -0,0 +1,15 @@
+package com.shkpr.service.customgateway.zydma.controller;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("${gateway.routes.zydma}/test")
+public class TeatController {
+
+    @GetMapping("test")
+    public void test() {
+
+    }
+}

+ 0 - 4
custom-gateway-zydma/src/main/java/com/shkpr/service/zydma/controller/TeatController.java

@@ -1,4 +0,0 @@
-package com.shkpr.service.zydma.controller;
-
-public class TeatController {
-}

+ 1 - 1
custom-gateway-zydma/src/test/java/com/shkpr/service/zydma/ZydmApplicationTests.java

@@ -1,4 +1,4 @@
-package com.shkpr.service.zydma;
+package com.shkpr.service.customgateway.zydma;
 
 import junit.framework.Test;
 import junit.framework.TestCase;