diff --git a/ruoyi-gateway/pom.xml b/ruoyi-gateway/pom.xml
index 8dc7634aa..8fb644c23 100644
--- a/ruoyi-gateway/pom.xml
+++ b/ruoyi-gateway/pom.xml
@@ -118,11 +118,6 @@
${kotlin.version}
test
-
- org.jetbrains.kotlin
- kotlin-stdlib-jdk8
- ${kotlin.version}
-
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 ef197deb5..5544c2456 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
@@ -1,41 +1,51 @@
-package com.ruoyi.gateway.handler;
-
-import java.io.IOException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-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 com.ruoyi.common.core.exception.CaptchaException;
-import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.gateway.service.ValidateCodeService;
-import reactor.core.publisher.Mono;
-
-/**
- * 验证码获取
- *
- * @author ruoyi
- */
-@Component
-public class ValidateCodeHandler implements HandlerFunction
-{
- @Autowired
- private ValidateCodeService validateCodeService;
-
- @Override
- public Mono handle(ServerRequest serverRequest)
- {
- AjaxResult ajax;
- try
- {
- ajax = validateCodeService.createCaptcha();
- }
- catch (CaptchaException | IOException e)
- {
- return Mono.error(e);
- }
- return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
- }
-}
+package com.ruoyi.gateway.handler;
+
+import java.io.IOException;
+import java.util.Objects;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+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 com.ruoyi.common.core.exception.CaptchaException;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.gateway.service.ValidateCodeService;
+import reactor.core.publisher.Mono;
+
+/**
+ * 验证码获取
+ *
+ * @author ruoyi
+ */
+@Component
+public class ValidateCodeHandler implements HandlerFunction
+{
+ @Autowired
+ private ValidateCodeService validateCodeService;
+
+ @Override
+ public Mono handle(ServerRequest serverRequest)
+ {
+ AjaxResult ajax;
+ try
+ {
+ switch (serverRequest.queryParam("type").orElse("image")) {
+ case "sms":
+ if (Objects.nonNull(serverRequest.queryParam("receiver").orElse(null))) {
+ ajax = validateCodeService.createSMSCaptcha(serverRequest.queryParam("receiver").orElse(null));
+ break;
+ }
+ default:
+ ajax = validateCodeService.createCaptcha();
+ }
+ }
+ catch (CaptchaException | IOException 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 615fb07bb..051631a0a 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
@@ -1,23 +1,28 @@
-package com.ruoyi.gateway.service;
-
-import java.io.IOException;
-import com.ruoyi.common.core.exception.CaptchaException;
-import com.ruoyi.common.core.web.domain.AjaxResult;
-
-/**
- * 验证码处理
- *
- * @author ruoyi
- */
-public interface ValidateCodeService
-{
- /**
- * 生成验证码
- */
- public AjaxResult createCaptcha() throws IOException, CaptchaException;
-
- /**
- * 校验验证码
- */
- public void checkCaptcha(String key, String value) throws CaptchaException;
-}
+package com.ruoyi.gateway.service;
+
+import java.io.IOException;
+import com.ruoyi.common.core.exception.CaptchaException;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+
+/**
+ * 验证码处理
+ *
+ * @author ruoyi
+ */
+public interface ValidateCodeService
+{
+ /**
+ * 生成图片验证码
+ */
+ public AjaxResult createCaptcha() throws IOException, CaptchaException;
+
+ /**
+ * 生成短信验证码
+ */
+ public AjaxResult createSMSCaptcha(String receiver) throws IOException, CaptchaException;
+
+ /**
+ * 校验验证码
+ */
+ public void checkCaptcha(String key, String value) 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 24f8274d0..e7367344b 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
@@ -103,6 +103,25 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
return ajax;
}
+ @Override
+ public AjaxResult createSMSCaptcha(String receiver) throws IOException, CaptchaException {
+ AjaxResult ajax = AjaxResult.success();
+ boolean captchaEnabled = captchaProperties.getEnabled();
+ ajax.put("captchaEnabled", captchaEnabled);
+ if (!captchaEnabled)
+ {
+ return ajax;
+ }
+ // 保存验证码信息
+ String uuid = IdUtils.simpleUUID();
+ String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
+ String code = captchaProducerNumber.createText();
+ redisService.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
+ ajax.put("code", code);
+ ajax.put("uuid", uuid);
+ return ajax;
+ }
+
/**
* 校验验证码
*/
diff --git a/ruoyi-gateway/src/main/kotlin/com/ruoyi/gateway/config/CorsFilter.kt b/ruoyi-gateway/src/main/kotlin/com/ruoyi/gateway/config/CorsConfig.kt
similarity index 100%
rename from ruoyi-gateway/src/main/kotlin/com/ruoyi/gateway/config/CorsFilter.kt
rename to ruoyi-gateway/src/main/kotlin/com/ruoyi/gateway/config/CorsConfig.kt