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] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=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()); }