From db68871646b9bb655f71f24284b3664b2007e438 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 18 May 2025 22:25:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/RenExceptionHandler.java | 6 +++--- .../modules/sys/loginControllerTest.java | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java b/main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java index df9023ae..f6b19d31 100644 --- a/main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java +++ b/main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java @@ -1,5 +1,8 @@ package xiaozhi.common.exception; +import java.util.List; +import java.util.Objects; + import org.apache.shiro.authz.UnauthorizedException; import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.dao.DuplicateKeyException; @@ -13,8 +16,6 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import xiaozhi.common.utils.Result; -import java.util.List; -import java.util.Objects; /** * 异常处理器 * Copyright (c) 人人开源 All rights reserved. @@ -67,7 +68,6 @@ public class RenExceptionHandler { @ExceptionHandler(MethodArgumentNotValidException.class) public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException ex) { - StringBuilder sb = new StringBuilder(); List allErrors = ex.getBindingResult().getAllErrors(); String errorMsg = allErrors.stream() .filter(Objects::nonNull) diff --git a/main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java b/main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java index 777abbf9..5cc39967 100644 --- a/main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java +++ b/main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java @@ -1,15 +1,16 @@ package xiaozhi.modules.sys; -import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; + +import lombok.extern.slf4j.Slf4j; import xiaozhi.modules.security.controller.LoginController; import xiaozhi.modules.security.dto.LoginDTO; +import xiaozhi.modules.security.dto.SmsVerificationDTO; import xiaozhi.modules.sys.dto.RetrievePasswordDTO; - @Slf4j @SpringBootTest @ActiveProfiles("dev") @@ -28,23 +29,27 @@ class loginControllerTest { } @Test - public void testSmsVerification(){ + public void testSmsVerification() { try { - loginController.smsVerification("手机号码"); - }catch (Exception e){ + SmsVerificationDTO smsVerificationDTO = new SmsVerificationDTO(); + smsVerificationDTO.setPhone("手机号码"); + smsVerificationDTO.setCaptchaId("123456"); + smsVerificationDTO.setCaptcha("123456"); + loginController.smsVerification(smsVerificationDTO); + } catch (Exception e) { System.out.println(e.getMessage()); } } @Test - public void testRetrievePassword(){ + public void testRetrievePassword() { try { RetrievePasswordDTO retrievePasswordDTO = new RetrievePasswordDTO(); retrievePasswordDTO.setCode("123456"); retrievePasswordDTO.setPhone("手机号码"); retrievePasswordDTO.setPassword("密码"); loginController.retrievePassword(retrievePasswordDTO); - }catch (Exception e){ + } catch (Exception e) { System.out.println(e.getMessage()); } From f242d43f73f3de06cc5d3e36973b6600f207f33f Mon Sep 17 00:00:00 2001 From: Sakura-RanChen <1908198662@qq.com> Date: Mon, 19 May 2025 14:15:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=BE=E5=9B=9E?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/apis/module/user.js | 24 ++ main/manager-web/src/router/index.js | 7 + main/manager-web/src/views/login.vue | 4 + .../src/views/retrievePassword.vue | 274 ++++++++++++++++++ 4 files changed, 309 insertions(+) create mode 100644 main/manager-web/src/views/retrievePassword.vue diff --git a/main/manager-web/src/apis/module/user.js b/main/manager-web/src/apis/module/user.js index 1ad28b2e..6c16c3e6 100755 --- a/main/manager-web/src/apis/module/user.js +++ b/main/manager-web/src/apis/module/user.js @@ -169,4 +169,28 @@ export default { }); }).send(); }, + // 找回用户密码 + retrievePassword(passwordData, callback, failCallback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/user/retrieve-password`) + .method('PUT') + .data({ + phone: passwordData.phone, + code: passwordData.code, + password: passwordData.password + }) + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail((err) => { + RequestService.clearRequestTime(); + failCallback(err); + }) + .networkFail(() => { + RequestService.reAjaxFun(() => { + this.retrievePassword(passwordData, callback, failCallback); + }); + }).send() + } } diff --git a/main/manager-web/src/router/index.js b/main/manager-web/src/router/index.js index a19b4ec6..49ee7e4c 100644 --- a/main/manager-web/src/router/index.js +++ b/main/manager-web/src/router/index.js @@ -39,6 +39,13 @@ const routes = [ return import('../views/register.vue') } }, + { + path: '/retrieve-password', + name: 'RetrievePassword', + component: function () { + return import('../views/retrievePassword.vue') + } + }, // 设备管理页面路由 { path: '/device-management', diff --git a/main/manager-web/src/views/login.vue b/main/manager-web/src/views/login.vue index f082721e..2cc42e45 100644 --- a/main/manager-web/src/views/login.vue +++ b/main/manager-web/src/views/login.vue @@ -56,6 +56,7 @@
新用户注册
+
忘记密码?
@@ -214,6 +215,9 @@ export default { goToRegister() { goToPage('/register') }, + goToForgetPassword() { + goToPage('/retrieve-password') + }, } } diff --git a/main/manager-web/src/views/retrievePassword.vue b/main/manager-web/src/views/retrievePassword.vue new file mode 100644 index 00000000..49b8c1e4 --- /dev/null +++ b/main/manager-web/src/views/retrievePassword.vue @@ -0,0 +1,274 @@ + + + + +