diff --git a/osc-commons/pom.xml b/osc-commons/pom.xml index cac8e48..ebba769 100644 --- a/osc-commons/pom.xml +++ b/osc-commons/pom.xml @@ -6,7 +6,7 @@ com.zwc osc-commons - 1.4.1 + 1.4.2 osc-commons @@ -46,7 +46,7 @@ - 2.7.0 + 2.9.2 diff --git a/osc-service/osc-base-service/osc-base-service-api/pom.xml b/osc-service/osc-base-service/osc-base-service-api/pom.xml index 71ded58..1a0921b 100644 --- a/osc-service/osc-base-service/osc-base-service-api/pom.xml +++ b/osc-service/osc-base-service/osc-base-service-api/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-base-service - 1.4.1 + 1.4.2 com.zwc osc-base-service-api - 1.4.1 + 1.4.2 osc-base-service-api diff --git a/osc-service/osc-base-service/osc-base-service-core/pom.xml b/osc-service/osc-base-service/osc-base-service-core/pom.xml index 34b17a2..417cf33 100644 --- a/osc-service/osc-base-service/osc-base-service-core/pom.xml +++ b/osc-service/osc-base-service/osc-base-service-core/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-base-service - 1.4.1 + 1.4.2 com.zwc osc-base-service-core - 1.4.1 + 1.4.2 osc-base-service-core @@ -40,7 +40,7 @@ com.zwc osc-base-service-api - 1.4.1 + 1.4.2 diff --git a/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/controller/AUseBFeignController.java b/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/controller/AUseBFeignController.java index 6406bb3..ec7ee6f 100644 --- a/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/controller/AUseBFeignController.java +++ b/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/controller/AUseBFeignController.java @@ -23,7 +23,7 @@ public class AUseBFeignController { /* * @ClassName FeignController - * @Desc TODO 通过 log-service 服务名调用 b() 方法 + * @Desc TODO 通过 log-service-core 服务名调用 b() 方法 * @Date 2019/5/20 23:13 * @Version 1.0 */ diff --git a/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/feign/FeignApi.java b/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/feign/FeignApi.java index 9fb04a6..0cc8ceb 100644 --- a/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/feign/FeignApi.java +++ b/osc-service/osc-base-service/osc-base-service-core/src/main/java/com/zwc/base/feign/FeignApi.java @@ -10,12 +10,12 @@ * @Date 2019/5/20 23:21 * @Version 1.0 */ -@FeignClient(value = "log-service" , fallback = FeignApiFallBack.class) +@FeignClient(value = "log-service-core" , fallback = FeignApiFallBack.class) public interface FeignApi { /* * @ClassName FeignApi - * @Desc TODO 通过 log-service 服务名调用 b() 方法 + * @Desc TODO 通过 log-service-core 服务名调用 b() 方法 * @Date 2019/5/20 23:21 * @Version 1.0 */ diff --git a/osc-service/osc-base-service/osc-base-service-core/src/main/resources/application.yml b/osc-service/osc-base-service/osc-base-service-core/src/main/resources/application.yml index 2d49b71..22ba4f1 100644 --- a/osc-service/osc-base-service/osc-base-service-core/src/main/resources/application.yml +++ b/osc-service/osc-base-service/osc-base-service-core/src/main/resources/application.yml @@ -11,7 +11,7 @@ spring: ## 多个环境的公用配置 application: # 应用名称 - name: base-service + name: base-service-core # 配置 Flyway flyway: diff --git a/osc-service/osc-base-service/pom.xml b/osc-service/osc-base-service/pom.xml index 3d3d3e8..c65eb31 100644 --- a/osc-service/osc-base-service/pom.xml +++ b/osc-service/osc-base-service/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-service - 1.4.1 + 1.4.2 com.zwc osc-base-service - 1.4.1 + 1.4.2 osc-base-service diff --git a/osc-service/osc-gateway-service/pom.xml b/osc-service/osc-gateway-service/pom.xml index 1041296..1958fe2 100644 --- a/osc-service/osc-gateway-service/pom.xml +++ b/osc-service/osc-gateway-service/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-service - 1.4.1 + 1.4.2 com.zwc osc-gateway-service - 1.4.1 + 1.4.2 osc-gateway-service @@ -28,6 +28,12 @@ 1.2.47 osc-gateway + + + + + + 2.9.2 @@ -63,6 +69,17 @@ org.springframework.cloud spring-cloud-starter-zipkin + + + io.springfox + springfox-swagger2 + ${springfox.version} + + + io.springfox + springfox-swagger-ui + ${springfox.version} + diff --git a/osc-service/osc-gateway-service/src/main/.DS_Store b/osc-service/osc-gateway-service/src/main/.DS_Store index 63b728b..e025b8d 100644 Binary files a/osc-service/osc-gateway-service/src/main/.DS_Store and b/osc-service/osc-gateway-service/src/main/.DS_Store differ diff --git a/osc-service/osc-gateway-service/src/main/java/.DS_Store b/osc-service/osc-gateway-service/src/main/java/.DS_Store index 0a8bc21..963a959 100644 Binary files a/osc-service/osc-gateway-service/src/main/java/.DS_Store and b/osc-service/osc-gateway-service/src/main/java/.DS_Store differ diff --git a/osc-service/osc-gateway-service/src/main/java/com/.DS_Store b/osc-service/osc-gateway-service/src/main/java/com/.DS_Store index a4d8a6d..f9bd29b 100644 Binary files a/osc-service/osc-gateway-service/src/main/java/com/.DS_Store and b/osc-service/osc-gateway-service/src/main/java/com/.DS_Store differ diff --git a/osc-service/osc-gateway-service/src/main/java/com/zwc/.DS_Store b/osc-service/osc-gateway-service/src/main/java/com/zwc/.DS_Store index 6d1ac46..c85835a 100644 Binary files a/osc-service/osc-gateway-service/src/main/java/com/zwc/.DS_Store and b/osc-service/osc-gateway-service/src/main/java/com/zwc/.DS_Store differ diff --git a/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/.DS_Store b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/.DS_Store index 5008ddf..f5aa5e4 100644 Binary files a/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/.DS_Store and b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/.DS_Store differ diff --git a/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/config/MySwaggerResourceProvider.java b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/config/MySwaggerResourceProvider.java new file mode 100644 index 0000000..931462e --- /dev/null +++ b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/config/MySwaggerResourceProvider.java @@ -0,0 +1,71 @@ +package com.zwc.gateway.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.stereotype.Component; +import springfox.documentation.swagger.web.SwaggerResource; +import springfox.documentation.swagger.web.SwaggerResourcesProvider; + +import java.util.*; + +/** + * @ClassName MySwaggerResourceProvider + * @Desc TODO 聚合 Swagger + * @Date 2020/1/26 5:36 PM + * @Version 1.0 + */ +@Component +public class MySwaggerResourceProvider implements SwaggerResourcesProvider { + + /** + * 特定服务名称后缀 + */ + public static final String SERVICE_SUFFIX = "core"; + + /** + * 固定地址 + */ + public static final String FIXED_URL = "/v2/api-docs"; + + /** + * 网关路由 + */ + private final RouteLocator routeLocator; + + @Autowired(required = false) + public MySwaggerResourceProvider(RouteLocator routeLocator) { + this.routeLocator = routeLocator; + } + + @Override + public List get() { + // 返回结果 + List resources = new ArrayList<>(); + // 所有路由 + List routeHosts = new ArrayList<>(); + // 过滤并添加路由(只加载指定服务:如处理业务逻辑的服务) + routeLocator.getRoutes().filter(route -> route.getUri().getHost() != null) + .filter(route -> route.getUri().getHost().indexOf(SERVICE_SUFFIX.toUpperCase()) != -1) + .subscribe(route -> routeHosts.add(route.getUri().getHost())); + + // 去重已添加的地址 + Set dealed = new HashSet<>(); + // 遍历所有路由 + routeHosts.forEach(instance -> { + // 拼接地址,格式为:/ + 路由 + 固定地址 + String url = "/" + instance + FIXED_URL; + // 去重 + if (!dealed.contains(url)) { + dealed.add(url); + SwaggerResource swaggerResource = new SwaggerResource(); + swaggerResource.setUrl(url); + swaggerResource.setName(instance); + resources.add(swaggerResource); + } + }); + // 返回 + return resources; + } + +} diff --git a/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/hystrix/FallbackController.java b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/controller/hystrix/FallbackController.java similarity index 88% rename from osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/hystrix/FallbackController.java rename to osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/controller/hystrix/FallbackController.java index c9e43ee..6d772e1 100755 --- a/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/hystrix/FallbackController.java +++ b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/controller/hystrix/FallbackController.java @@ -1,4 +1,4 @@ -package com.zwc.gateway.hystrix; +package com.zwc.gateway.controller.hystrix; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/controller/swagger/SwaggerResourceController.java b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/controller/swagger/SwaggerResourceController.java new file mode 100644 index 0000000..f8d576f --- /dev/null +++ b/osc-service/osc-gateway-service/src/main/java/com/zwc/gateway/controller/swagger/SwaggerResourceController.java @@ -0,0 +1,45 @@ +package com.zwc.gateway.controller.swagger; + +import com.zwc.gateway.config.MySwaggerResourceProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.swagger.web.*; + +import java.util.List; + +/** + * @ClassName SwaggerResourceController + * @Desc TODO 重写核心接口 + * @Date 2020/1/26 6:38 PM + * @Version 1.0 + */ +@RestController +@RequestMapping("/swagger-resources") +public class SwaggerResourceController { + + private MySwaggerResourceProvider swaggerResourceProvider; + + @Autowired + public SwaggerResourceController(MySwaggerResourceProvider swaggerResourceProvider) { + this.swaggerResourceProvider = swaggerResourceProvider; + } + + @RequestMapping(value = "/configuration/security") + public ResponseEntity securityConfiguration() { + return new ResponseEntity<>(SecurityConfigurationBuilder.builder().build(), HttpStatus.OK); + } + + @RequestMapping(value = "/configuration/ui") + public ResponseEntity uiConfiguration() { + return new ResponseEntity<>(UiConfigurationBuilder.builder().build(), HttpStatus.OK); + } + + @RequestMapping + public ResponseEntity> swaggerResources() { + return new ResponseEntity<>(swaggerResourceProvider.get(), HttpStatus.OK); + } + +} diff --git a/osc-service/osc-gateway-service/src/main/resources/application.yml b/osc-service/osc-gateway-service/src/main/resources/application.yml index aa43d6f..78d5ac4 100644 --- a/osc-service/osc-gateway-service/src/main/resources/application.yml +++ b/osc-service/osc-gateway-service/src/main/resources/application.yml @@ -24,7 +24,7 @@ spring: # 路由标识(id:标识,具有唯一性) 综合 - id: route_base # 目标服务地址(uri:地址,请求转发后的地址) - uri: lb://base-service + uri: lb://BASE-SERVICE-CORE # 路由条件(predicates:断言,匹配 HTTP 请求内容) predicates: ## 转发地址格式为 uri,/baseService 部分会被下面的过滤器给截取掉 diff --git a/osc-service/osc-log-service/osc-log-service-api/pom.xml b/osc-service/osc-log-service/osc-log-service-api/pom.xml index 796ba97..755be11 100644 --- a/osc-service/osc-log-service/osc-log-service-api/pom.xml +++ b/osc-service/osc-log-service/osc-log-service-api/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-log-service - 1.4.1 + 1.4.2 com.zwc osc-log-service-api - 1.4.1 + 1.4.2 osc-log-service-api diff --git a/osc-service/osc-log-service/osc-log-service-core/pom.xml b/osc-service/osc-log-service/osc-log-service-core/pom.xml index 17e4c0e..c341107 100644 --- a/osc-service/osc-log-service/osc-log-service-core/pom.xml +++ b/osc-service/osc-log-service/osc-log-service-core/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-log-service - 1.4.1 + 1.4.2 com.zwc osc-log-service-core - 1.4.1 + 1.4.2 osc-log-service-core @@ -40,12 +40,12 @@ com.zwc osc-log-service-api - 1.4.1 + 1.4.2 com.zwc osc-base-service-api - 1.4.1 + 1.4.2 diff --git a/osc-service/osc-log-service/osc-log-service-core/src/main/resources/application.yml b/osc-service/osc-log-service/osc-log-service-core/src/main/resources/application.yml index 59e4c81..f873822 100644 --- a/osc-service/osc-log-service/osc-log-service-core/src/main/resources/application.yml +++ b/osc-service/osc-log-service/osc-log-service-core/src/main/resources/application.yml @@ -11,7 +11,7 @@ spring: ## 多个环境的公用配置 application: # 应用名称 - name: log-service + name: log-service-core # 配置 Flyway flyway: diff --git a/osc-service/osc-log-service/pom.xml b/osc-service/osc-log-service/pom.xml index 95a4d84..77be42c 100644 --- a/osc-service/osc-log-service/pom.xml +++ b/osc-service/osc-log-service/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-service - 1.4.1 + 1.4.2 com.zwc osc-log-service - 1.4.1 + 1.4.2 osc-log-service diff --git a/osc-service/osc-registry-service/pom.xml b/osc-service/osc-registry-service/pom.xml index c0dd945..4c1da13 100644 --- a/osc-service/osc-registry-service/pom.xml +++ b/osc-service/osc-registry-service/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-service - 1.4.1 + 1.4.2 com.zwc osc-registry-service - 1.4.1 + 1.4.2 osc-registry-service diff --git a/osc-service/osc-sleuth-service/pom.xml b/osc-service/osc-sleuth-service/pom.xml index 51fbcce..c4b8723 100644 --- a/osc-service/osc-sleuth-service/pom.xml +++ b/osc-service/osc-sleuth-service/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-service - 1.4.1 + 1.4.2 com.zwc osc-sleuth-service - 1.4.1 + 1.4.2 osc-sleuth-service diff --git a/osc-service/osc-turbine-service/pom.xml b/osc-service/osc-turbine-service/pom.xml index aa1ae7e..de9d2c5 100644 --- a/osc-service/osc-turbine-service/pom.xml +++ b/osc-service/osc-turbine-service/pom.xml @@ -7,13 +7,13 @@ com.zwc osc-service - 1.4.1 + 1.4.2 com.zwc osc-turbine-service - 1.4.1 + 1.4.2 osc-turbine-service diff --git a/osc-service/osc-turbine-service/src/main/resources/application.yml b/osc-service/osc-turbine-service/src/main/resources/application.yml index 3b9797a..6f7d338 100644 --- a/osc-service/osc-turbine-service/src/main/resources/application.yml +++ b/osc-service/osc-turbine-service/src/main/resources/application.yml @@ -25,7 +25,7 @@ eureka: turbine: # 监控的应用名称,多个以逗号隔开 - app-config: base-service, log-service + app-config: base-service-core, log-service-core aggregator: # 指定聚合哪些集群,默认为 default clusterConfig: default diff --git a/osc-service/pom.xml b/osc-service/pom.xml index 9cfa312..99d06dd 100644 --- a/osc-service/pom.xml +++ b/osc-service/pom.xml @@ -6,7 +6,7 @@ com.zwc osc-service - 1.4.1 + 1.4.2 osc-service @@ -62,7 +62,7 @@ https://index.docker.io/v1/ - 1.4.1 + 1.4.2