From 0556dbd111d25bd531778075b71b9650323843d3 Mon Sep 17 00:00:00 2001 From: 1332987 <13329870472@163.com> Date: Wed, 20 Apr 2022 16:15:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Didea=20=20=E4=B8=8D=E9=80=82?= =?UTF-8?q?=E5=BD=93=E7=9A=84=E9=98=BB=E5=A1=9E=E6=96=B9=E6=B3=95=E8=B0=83?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/gateway/handler/ValidateCodeHandler.java | 9 ++++----- .../com/ruoyi/gateway/service/ValidateCodeService.java | 2 +- .../gateway/service/impl/ValidateCodeServiceImpl.java | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/ValidateCodeHandler.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/ValidateCodeHandler.java index 547b7145..5c43a647 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/ValidateCodeHandler.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/ValidateCodeHandler.java @@ -3,7 +3,6 @@ package com.ruoyi.gateway.handler; import com.ruoyi.common.core.exception.CaptchaException; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.gateway.service.ValidateCodeService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.BodyInserters; @@ -12,7 +11,7 @@ import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.reactive.function.server.ServerResponse; import reactor.core.publisher.Mono; -import java.io.IOException; +import javax.annotation.Resource; /** * 验证码获取 @@ -21,7 +20,7 @@ import java.io.IOException; */ @Component public class ValidateCodeHandler implements HandlerFunction { - @Autowired + @Resource private ValidateCodeService validateCodeService; @Override @@ -29,9 +28,9 @@ public class ValidateCodeHandler implements HandlerFunction { AjaxResult ajax; try { ajax = validateCodeService.createCaptcha(); - } catch (CaptchaException | IOException e) { + return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax)); + } catch (CaptchaException e) { return Mono.error(e); } - return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax)); } } diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/ValidateCodeService.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/ValidateCodeService.java index 39afdda8..cd6a6a9f 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/ValidateCodeService.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/ValidateCodeService.java @@ -18,7 +18,7 @@ public interface ValidateCodeService { * @throws IOException / * @throws CaptchaException / */ - public AjaxResult createCaptcha() throws IOException, CaptchaException; + public AjaxResult createCaptcha() throws CaptchaException; /** * 校验验证码 diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/impl/ValidateCodeServiceImpl.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/impl/ValidateCodeServiceImpl.java index c6cdd359..04518cf9 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/impl/ValidateCodeServiceImpl.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/impl/ValidateCodeServiceImpl.java @@ -43,7 +43,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService { * 生成验证码 */ @Override - public AjaxResult createCaptcha() throws IOException, CaptchaException { + public AjaxResult createCaptcha() throws CaptchaException { AjaxResult ajax = AjaxResult.success(); boolean captchaOnOff = captchaProperties.getEnabled(); ajax.put("captchaOnOff", captchaOnOff);