From 1cb3ba4880e3ceb5a3bd1dfa4daf368d916404cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Tue, 17 May 2022 01:06:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(youlai-gateway):=20=E7=BD=91=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84=EF=BC=8Cswagger=E7=94=B1we?= =?UTF-8?q?bflux=E7=9A=84=E6=B3=A8=E8=A7=A3=E5=BC=8F=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=BA=E5=87=BD=E6=95=B0=E5=BC=8F=E7=BC=96=E7=A8=8B=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{kaptcha => }/config/CaptchaConfig.java | 4 +- .../SwaggerResourceConfig.java | 15 ++-- .../GatewayLogFilter.java} | 82 +++++++++++++++++- .../SecurityGlobalFilter.java | 2 +- .../{kaptcha => }/handler/CaptchaHandler.java | 8 +- .../swagger/SwaggerResourceHandler.java | 35 ++++++++ .../swagger/SwaggerSecurityHandler.java | 39 +++++++++ .../handler/swagger/SwaggerUiHandler.java | 41 +++++++++ .../java/com/youlai/gateway/log/TraceLog.java | 83 ------------------- .../youlai/gateway/router/CaptchaRouter.java | 10 +-- .../youlai/gateway/router/SwaggerRouter.java | 46 ++++++++++ .../gateway/swagger/SwaggerHandler.java | 53 ------------ .../{kaptcha => util}/KaptchaTextCreator.java | 2 +- .../youlai/gateway/util/ResponseUtils.java | 6 +- 14 files changed, 264 insertions(+), 162 deletions(-) rename youlai-gateway/src/main/java/com/youlai/gateway/{kaptcha => }/config/CaptchaConfig.java (96%) rename youlai-gateway/src/main/java/com/youlai/gateway/{swagger => config}/SwaggerResourceConfig.java (84%) rename youlai-gateway/src/main/java/com/youlai/gateway/{log/LogFilter.java => filter/GatewayLogFilter.java} (81%) rename youlai-gateway/src/main/java/com/youlai/gateway/{security => filter}/SecurityGlobalFilter.java (99%) rename youlai-gateway/src/main/java/com/youlai/gateway/{kaptcha => }/handler/CaptchaHandler.java (87%) create mode 100644 youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerResourceHandler.java create mode 100644 youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerSecurityHandler.java create mode 100644 youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerUiHandler.java delete mode 100644 youlai-gateway/src/main/java/com/youlai/gateway/log/TraceLog.java create mode 100644 youlai-gateway/src/main/java/com/youlai/gateway/router/SwaggerRouter.java delete mode 100644 youlai-gateway/src/main/java/com/youlai/gateway/swagger/SwaggerHandler.java rename youlai-gateway/src/main/java/com/youlai/gateway/{kaptcha => util}/KaptchaTextCreator.java (98%) diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/config/CaptchaConfig.java b/youlai-gateway/src/main/java/com/youlai/gateway/config/CaptchaConfig.java similarity index 96% rename from youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/config/CaptchaConfig.java rename to youlai-gateway/src/main/java/com/youlai/gateway/config/CaptchaConfig.java index 1cdcd6af8..7ce93445a 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/config/CaptchaConfig.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/config/CaptchaConfig.java @@ -1,4 +1,4 @@ -package com.youlai.gateway.kaptcha.config; +package com.youlai.gateway.config; import com.google.code.kaptcha.impl.DefaultKaptcha; import com.google.code.kaptcha.util.Config; @@ -35,7 +35,7 @@ public class CaptchaConfig { // KAPTCHA_SESSION_KEY properties.setProperty("kaptcha.session.key", "kaptchaCodeMath"); // 验证码文本生成器 - properties.setProperty("kaptcha.textproducer.impl", "com.youlai.gateway.kaptcha.KaptchaTextCreator"); + properties.setProperty("kaptcha.textproducer.impl", "com.youlai.gateway.util.KaptchaTextCreator"); // 验证码文本字符间距 默认为2 properties.setProperty("kaptcha.textproducer.char.space", "3"); // 验证码文本字符长度 默认为5 diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/swagger/SwaggerResourceConfig.java b/youlai-gateway/src/main/java/com/youlai/gateway/config/SwaggerResourceConfig.java similarity index 84% rename from youlai-gateway/src/main/java/com/youlai/gateway/swagger/SwaggerResourceConfig.java rename to youlai-gateway/src/main/java/com/youlai/gateway/config/SwaggerResourceConfig.java index cb1c55dc1..67762f9e5 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/swagger/SwaggerResourceConfig.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/config/SwaggerResourceConfig.java @@ -1,6 +1,6 @@ -package com.youlai.gateway.swagger; +package com.youlai.gateway.config; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.gateway.config.GatewayProperties; import org.springframework.cloud.gateway.route.RouteLocator; @@ -14,22 +14,19 @@ import java.util.ArrayList; import java.util.List; /** - * @Author haoxr - * @Date 2021-02-25 16:21 - * @Version 1.0.0 - * @ https://gitee.com/xiaoym/swagger-bootstrap-ui-demo/blob/master/knife4j-spring-cloud-gateway/service-doc/src/main/java/com/xiaominfo/swagger/service/doc/config/SwaggerResourceConfig.java + * @author haoxr + * @date 2022/5/17 16:21 */ -@Slf4j @Component @Primary -@AllArgsConstructor +@RequiredArgsConstructor +@Slf4j public class SwaggerResourceConfig implements SwaggerResourcesProvider { private final RouteLocator routeLocator; private final GatewayProperties gatewayProperties; - @Override public List get() { List resources = new ArrayList<>(); diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/log/LogFilter.java b/youlai-gateway/src/main/java/com/youlai/gateway/filter/GatewayLogFilter.java similarity index 81% rename from youlai-gateway/src/main/java/com/youlai/gateway/log/LogFilter.java rename to youlai-gateway/src/main/java/com/youlai/gateway/filter/GatewayLogFilter.java index 980bc2f0a..509f6247b 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/log/LogFilter.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/filter/GatewayLogFilter.java @@ -1,8 +1,9 @@ -package com.youlai.gateway.log; +package com.youlai.gateway.filter; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.reactivestreams.Publisher; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -51,7 +52,7 @@ import java.util.stream.Collectors; ) @Component @Slf4j -public class LogFilter implements GlobalFilter, Ordered { +public class GatewayLogFilter implements GlobalFilter, Ordered { private final List> messageReaders = HandlerStrategies.withDefaults().messageReaders(); @@ -216,4 +217,81 @@ public class LogFilter implements GlobalFilter, Ordered { public int getOrder() { return -1; } + + + + + @Data + public static class TraceLog { + + /** + * 请求路径 + */ + private String requestPath; + + /** + * 请求方法 + */ + private String requestMethod; + + /** + * 查询参数 + */ + private String queryParams; + + /** + * 请求载荷 + */ + private String requestBody; + + /** + * 响应数据 + */ + private String responseBody; + + /** + * 请求时间 + */ + private String requestTime; + + /** + * 响应时间 + */ + private String responseTime; + + /** + * 执行耗时(毫秒) + */ + private Long executeTime; + + + public String toRequestString() { + return + "^^^^^^^^请求日志^^^^^^^^: " + requestMethod + ':' + requestPath + '\n' + + "查询参数:" + queryParams + '\n' + + "请求载荷:" + requestBody + '\n' + + "请求时间:" + requestTime; + } + + public String toResponseString() { + return + "$$$$$$$$响应日志$$$$$$$$: " + requestMethod + ':' + requestPath + '\n' + + "请求时间:" + requestTime + '\n' + + "响应时间:" + responseTime + '\n' + + "响应数据:" + responseBody + '\n' + + "执行耗时:" + executeTime + "毫秒"; + } + + @Override + public String toString() { + return "========网关请求响应日志========\n" + + "请求路径:" + requestPath + '\n' + + "请求方法:" + requestMethod + '\n' + + "请求参数:" + requestBody + '\n' + + "响应数据:" + responseBody + '\n' + + "请求时间:" + requestTime + '\n' + + "响应时间:" + responseTime + '\n' + + "执行耗时:" + executeTime + "毫秒"; + } + } } diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/security/SecurityGlobalFilter.java b/youlai-gateway/src/main/java/com/youlai/gateway/filter/SecurityGlobalFilter.java similarity index 99% rename from youlai-gateway/src/main/java/com/youlai/gateway/security/SecurityGlobalFilter.java rename to youlai-gateway/src/main/java/com/youlai/gateway/filter/SecurityGlobalFilter.java index 5a180776d..dbdf6553c 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/security/SecurityGlobalFilter.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/filter/SecurityGlobalFilter.java @@ -1,4 +1,4 @@ -package com.youlai.gateway.security; +package com.youlai.gateway.filter; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/handler/CaptchaHandler.java b/youlai-gateway/src/main/java/com/youlai/gateway/handler/CaptchaHandler.java similarity index 87% rename from youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/handler/CaptchaHandler.java rename to youlai-gateway/src/main/java/com/youlai/gateway/handler/CaptchaHandler.java index 9ccd66dea..e0d753611 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/handler/CaptchaHandler.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/handler/CaptchaHandler.java @@ -1,4 +1,4 @@ -package com.youlai.gateway.kaptcha.handler; +package com.youlai.gateway.handler; import cn.hutool.core.codec.Base64; import cn.hutool.core.io.FastByteArrayOutputStream; @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; /** - * @author haoxr + * @author haoxr * @date 2021/10/4 */ @Component @@ -35,7 +35,7 @@ public class CaptchaHandler implements HandlerFunction { private final StringRedisTemplate redisTemplate; @Override - public Mono handle(ServerRequest serverRequest) { + public Mono handle(ServerRequest request) { // 生成验证码 String capText = producer.createText(); String capStr = capText.substring(0, capText.lastIndexOf("@")); @@ -56,6 +56,6 @@ public class CaptchaHandler implements HandlerFunction { resultMap.put("uuid", uuid); resultMap.put("img", Base64.encode(os.toByteArray())); - return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(Result.success(resultMap))); + return ServerResponse.ok().body(BodyInserters.fromValue(Result.success(resultMap))); } } diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerResourceHandler.java b/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerResourceHandler.java new file mode 100644 index 000000000..e3b8f0738 --- /dev/null +++ b/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerResourceHandler.java @@ -0,0 +1,35 @@ +package com.youlai.gateway.handler.swagger; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; +import springfox.documentation.swagger.web.SwaggerResourcesProvider; + + +/** + * 聚合各个服务的swagger接口 + * + * @author haoxr + * @date 2022/5/17 0:53 + */ +@Component +@RequiredArgsConstructor +public class SwaggerResourceHandler implements HandlerFunction { + + private final SwaggerResourcesProvider swaggerResources; + + @Override + public Mono handle(ServerRequest request) { + Mono responseMono = ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters + .fromValue(swaggerResources.get())); + return responseMono; + } + +} diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerSecurityHandler.java b/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerSecurityHandler.java new file mode 100644 index 000000000..7a772e58e --- /dev/null +++ b/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerSecurityHandler.java @@ -0,0 +1,39 @@ +package com.youlai.gateway.handler.swagger; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; +import springfox.documentation.swagger.web.SecurityConfiguration; +import springfox.documentation.swagger.web.SecurityConfigurationBuilder; + +import java.util.Optional; + + +/** + * 权限处理器 + * + * @author haoxr + * @date 2022/5/17 + */ +@Component +public class SwaggerSecurityHandler implements HandlerFunction { + + @Autowired(required = false) + private SecurityConfiguration securityConfiguration; + + @Override + public Mono handle(ServerRequest request) { + Mono responseMono = ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters + .fromValue(Optional.ofNullable(securityConfiguration) + .orElse(SecurityConfigurationBuilder.builder().build()))); + return responseMono; + } +} diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerUiHandler.java b/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerUiHandler.java new file mode 100644 index 000000000..4b9bedde8 --- /dev/null +++ b/youlai-gateway/src/main/java/com/youlai/gateway/handler/swagger/SwaggerUiHandler.java @@ -0,0 +1,41 @@ +package com.youlai.gateway.handler.swagger; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; +import springfox.documentation.swagger.web.UiConfiguration; +import springfox.documentation.swagger.web.UiConfigurationBuilder; + +import java.util.Optional; + + +/** + * UI处理器 + * + * @author haoxr + * @date 2022/5/17 0:51 + */ +@Component +public class SwaggerUiHandler implements HandlerFunction { + + + @Autowired(required = false) + private UiConfiguration uiConfiguration; + + @Override + public Mono handle(ServerRequest request) { + Mono responseMono = ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters + .fromValue(Optional.ofNullable(uiConfiguration) + .orElse(UiConfigurationBuilder.builder().build()))); + return responseMono; + } + +} diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/log/TraceLog.java b/youlai-gateway/src/main/java/com/youlai/gateway/log/TraceLog.java deleted file mode 100644 index 0ff8961b6..000000000 --- a/youlai-gateway/src/main/java/com/youlai/gateway/log/TraceLog.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.youlai.gateway.log; - -import lombok.Data; - -/** - * 请求响应日志实体对象 - * - * @author haoxr - * @date 2022/4/28 16:54 - */ -@Data -public class TraceLog { - - /** - * 请求路径 - */ - private String requestPath; - - /** - * 请求方法 - */ - private String requestMethod; - - /** - * 查询参数 - */ - private String queryParams; - - /** - * 请求载荷 - */ - private String requestBody; - - /** - * 响应数据 - */ - private String responseBody; - - /** - * 请求时间 - */ - private String requestTime; - - /** - * 响应时间 - */ - private String responseTime; - - /** - * 执行耗时(毫秒) - */ - private Long executeTime; - - - public String toRequestString() { - return - "^^^^^^^^请求日志^^^^^^^^: " + requestMethod + ':' + requestPath + '\n' + - "查询参数:" + queryParams + '\n' + - "请求载荷:" + requestBody + '\n' + - "请求时间:" + requestTime; - } - - public String toResponseString() { - return - "$$$$$$$$响应日志$$$$$$$$: " + requestMethod + ':' + requestPath + '\n' + - "请求时间:" + requestTime + '\n' + - "响应时间:" + responseTime + '\n' + - "响应数据:" + responseBody + '\n' + - "执行耗时:" + executeTime + "毫秒"; - } - - @Override - public String toString() { - return "========网关请求响应日志========\n" + - "请求路径:" + requestPath + '\n' + - "请求方法:" + requestMethod + '\n' + - "请求参数:" + requestBody + '\n' + - "响应数据:" + responseBody + '\n' + - "请求时间:" + requestTime + '\n' + - "响应时间:" + responseTime + '\n' + - "执行耗时:" + executeTime + "毫秒"; - } -} diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/router/CaptchaRouter.java b/youlai-gateway/src/main/java/com/youlai/gateway/router/CaptchaRouter.java index 4b9a2dc64..168761487 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/router/CaptchaRouter.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/router/CaptchaRouter.java @@ -1,6 +1,6 @@ package com.youlai.gateway.router; -import com.youlai.gateway.kaptcha.handler.CaptchaHandler; +import com.youlai.gateway.handler.CaptchaHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; @@ -10,16 +10,16 @@ import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; /** - * 图片验证码路由 + * 验证码路由 * - * @author haoxr - * @date 2021/10/4 + * @author haoxr + * @date 2022/5/16 */ @Configuration public class CaptchaRouter { @Bean - public RouterFunction routeFunction(CaptchaHandler captchaHandler) { + public RouterFunction captchaRouterFunction(CaptchaHandler captchaHandler) { return RouterFunctions .route(RequestPredicates.GET("/captcha") .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), captchaHandler::handle); diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/router/SwaggerRouter.java b/youlai-gateway/src/main/java/com/youlai/gateway/router/SwaggerRouter.java new file mode 100644 index 000000000..8917c0529 --- /dev/null +++ b/youlai-gateway/src/main/java/com/youlai/gateway/router/SwaggerRouter.java @@ -0,0 +1,46 @@ +package com.youlai.gateway.router; + +import com.youlai.gateway.handler.swagger.SwaggerResourceHandler; +import com.youlai.gateway.handler.swagger.SwaggerSecurityHandler; +import com.youlai.gateway.handler.swagger.SwaggerUiHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +/** + * Swagger路由 + * + * @author haoxr + * @date 2022/5/16 16:34 + */ +@Configuration +@RequiredArgsConstructor +public class SwaggerRouter { + + /** + * 聚合各个服务的swagger接口 + */ + private final SwaggerResourceHandler swaggerResourceHandler; + /** + * 权限处理器 + */ + private final SwaggerSecurityHandler swaggerSecurityHandler; + /** + * UI处理器 + */ + private final SwaggerUiHandler swaggerUiHandler; + + @Bean + public RouterFunction swaggerRouterFunction() { + return RouterFunctions + .route(RequestPredicates.GET("/swagger-resources/configuration/security").and(RequestPredicates.accept(MediaType.ALL)), swaggerSecurityHandler::handle) + .andRoute(RequestPredicates.GET("/swagger-resources/configuration/ui").and(RequestPredicates.accept(MediaType.ALL)), swaggerUiHandler::handle) + .andRoute(RequestPredicates.GET("/swagger-resources").and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler::handle); + } + +} diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/swagger/SwaggerHandler.java b/youlai-gateway/src/main/java/com/youlai/gateway/swagger/SwaggerHandler.java deleted file mode 100644 index ec8d41cde..000000000 --- a/youlai-gateway/src/main/java/com/youlai/gateway/swagger/SwaggerHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.youlai.gateway.swagger; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.*; - -import java.util.Optional; - -/** - * @author xianrui - * @Date 2021-02-25 16:34 - * @Version 1.0.0 - * @ https://gitee.com/xiaoym/swagger-bootstrap-ui-demo/blob/masterknife4j-spring-cloud-gateway/service-doc/src/main/java/com/xiaominfo/swagger/service/doc/handler/SwaggerHandler.java - */ -@RestController -public class SwaggerHandler { - - @Autowired(required = false) - private SecurityConfiguration securityConfiguration; - - @Autowired(required = false) - private UiConfiguration uiConfiguration; - - private final SwaggerResourcesProvider swaggerResources; - - @Autowired - public SwaggerHandler(SwaggerResourcesProvider swaggerResources) { - this.swaggerResources = swaggerResources; - } - - - @GetMapping("/swagger-resources/configuration/security") - public Mono> securityConfiguration() { - return Mono.just(new ResponseEntity<>( - Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK)); - } - - @GetMapping("/swagger-resources/configuration/ui") - public Mono> uiConfiguration() { - return Mono.just(new ResponseEntity<>( - Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK)); - } - - @GetMapping("/swagger-resources") - public Mono swaggerResources() { - return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK))); - } - -} diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/KaptchaTextCreator.java b/youlai-gateway/src/main/java/com/youlai/gateway/util/KaptchaTextCreator.java similarity index 98% rename from youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/KaptchaTextCreator.java rename to youlai-gateway/src/main/java/com/youlai/gateway/util/KaptchaTextCreator.java index 21ce6fdff..4862898fa 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/kaptcha/KaptchaTextCreator.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/util/KaptchaTextCreator.java @@ -1,4 +1,4 @@ -package com.youlai.gateway.kaptcha; +package com.youlai.gateway.util; import com.google.code.kaptcha.text.impl.DefaultTextCreator; diff --git a/youlai-gateway/src/main/java/com/youlai/gateway/util/ResponseUtils.java b/youlai-gateway/src/main/java/com/youlai/gateway/util/ResponseUtils.java index bba092665..1cb8e0513 100644 --- a/youlai-gateway/src/main/java/com/youlai/gateway/util/ResponseUtils.java +++ b/youlai-gateway/src/main/java/com/youlai/gateway/util/ResponseUtils.java @@ -14,8 +14,10 @@ import reactor.core.publisher.Mono; import java.nio.charset.StandardCharsets; /** - * @Author hxr - * @Date 2021-01-29 13:30 + * 异常响应工具类 + * + * @Author haoxr + * @Date 2021/01/29 13:30 */ public class ResponseUtils {