From 575340ec49388ae4c875c123ba8baa71a0b5396f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=B2=90?= Date: Mon, 17 Oct 2022 12:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9F=AD=E4=BF=A1=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/maku/security/config/LoginConfig.java | 38 ++++++++++++++++++++++ .../maku/system/controller/SysAuthController.java | 5 ++- .../net/maku/system/service/SysAuthService.java | 2 +- .../system/service/impl/SysAuthServiceImpl.java | 4 +-- maku-server/pom.xml | 10 +++--- 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 maku-boot-system/src/main/java/net/maku/security/config/LoginConfig.java diff --git a/maku-boot-system/src/main/java/net/maku/security/config/LoginConfig.java b/maku-boot-system/src/main/java/net/maku/security/config/LoginConfig.java new file mode 100644 index 0000000..90b221d --- /dev/null +++ b/maku-boot-system/src/main/java/net/maku/security/config/LoginConfig.java @@ -0,0 +1,38 @@ +package net.maku.security.config; + +import net.maku.api.module.message.SmsApi; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +/** + * 登录配置信息 + * + * @author 阿沐 babamu@126.com + */ +@Configuration +public class LoginConfig { + + @Bean + @ConditionalOnMissingBean + SmsApi smsApi() { + return new SmsApi() { + @Override + public boolean send(String mobile, Map params) { + return false; + } + + @Override + public boolean sendCode(String mobile, String key, String value) { + return false; + } + + @Override + public boolean verifyCode(String mobile, String code) { + return false; + } + }; + } +} diff --git a/maku-boot-system/src/main/java/net/maku/system/controller/SysAuthController.java b/maku-boot-system/src/main/java/net/maku/system/controller/SysAuthController.java index 0446336..eb3b7a7 100644 --- a/maku-boot-system/src/main/java/net/maku/system/controller/SysAuthController.java +++ b/maku-boot-system/src/main/java/net/maku/system/controller/SysAuthController.java @@ -47,7 +47,10 @@ public class SysAuthController { @PostMapping("send/code") @Operation(summary = "发送短信验证码") public Result sendCode(String mobile) { - sysAuthService.sendCode(mobile); + boolean flag = sysAuthService.sendCode(mobile); + if (!flag) { + return Result.error("短信发送失败!"); + } return Result.ok(); } diff --git a/maku-boot-system/src/main/java/net/maku/system/service/SysAuthService.java b/maku-boot-system/src/main/java/net/maku/system/service/SysAuthService.java index c307402..61bc2b0 100644 --- a/maku-boot-system/src/main/java/net/maku/system/service/SysAuthService.java +++ b/maku-boot-system/src/main/java/net/maku/system/service/SysAuthService.java @@ -30,7 +30,7 @@ public interface SysAuthService { * * @param mobile 手机号 */ - void sendCode(String mobile); + boolean sendCode(String mobile); /** * 退出登录 diff --git a/maku-boot-system/src/main/java/net/maku/system/service/impl/SysAuthServiceImpl.java b/maku-boot-system/src/main/java/net/maku/system/service/impl/SysAuthServiceImpl.java index 4586eab..921ab80 100644 --- a/maku-boot-system/src/main/java/net/maku/system/service/impl/SysAuthServiceImpl.java +++ b/maku-boot-system/src/main/java/net/maku/system/service/impl/SysAuthServiceImpl.java @@ -95,7 +95,7 @@ public class SysAuthServiceImpl implements SysAuthService { } @Override - public void sendCode(String mobile) { + public boolean sendCode(String mobile) { // 生成6位验证码 String code = RandomUtil.randomNumbers(6); @@ -105,7 +105,7 @@ public class SysAuthServiceImpl implements SysAuthService { } // 发送短信 - smsApi.sendCode(mobile, "code", code); + return smsApi.sendCode(mobile, "code", code); } @Override diff --git a/maku-server/pom.xml b/maku-server/pom.xml index 15d4829..1da61c6 100644 --- a/maku-server/pom.xml +++ b/maku-server/pom.xml @@ -25,11 +25,11 @@ - - net.maku - maku-module-message - ${revision} - + + + + + com.github.xiaoymin knife4j-springdoc-ui