Merge remote-tracking branch 'origin/main'

This commit is contained in:
AMEN
2025-05-18 23:34:53 +08:00
2 changed files with 15 additions and 10 deletions
@@ -1,5 +1,8 @@
package xiaozhi.common.exception; package xiaozhi.common.exception;
import java.util.List;
import java.util.Objects;
import org.apache.shiro.authz.UnauthorizedException; import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
@@ -13,8 +16,6 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import xiaozhi.common.utils.Result; import xiaozhi.common.utils.Result;
import java.util.List;
import java.util.Objects;
/** /**
* 异常处理器 * 异常处理器
* Copyright (c) 人人开源 All rights reserved. * Copyright (c) 人人开源 All rights reserved.
@@ -67,7 +68,6 @@ public class RenExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class) @ExceptionHandler(MethodArgumentNotValidException.class)
public Result<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException ex) { public Result<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException ex) {
StringBuilder sb = new StringBuilder();
List<ObjectError> allErrors = ex.getBindingResult().getAllErrors(); List<ObjectError> allErrors = ex.getBindingResult().getAllErrors();
String errorMsg = allErrors.stream() String errorMsg = allErrors.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
@@ -1,15 +1,16 @@
package xiaozhi.modules.sys; package xiaozhi.modules.sys;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import lombok.extern.slf4j.Slf4j;
import xiaozhi.modules.security.controller.LoginController; import xiaozhi.modules.security.controller.LoginController;
import xiaozhi.modules.security.dto.LoginDTO; import xiaozhi.modules.security.dto.LoginDTO;
import xiaozhi.modules.security.dto.SmsVerificationDTO;
import xiaozhi.modules.sys.dto.RetrievePasswordDTO; import xiaozhi.modules.sys.dto.RetrievePasswordDTO;
@Slf4j @Slf4j
@SpringBootTest @SpringBootTest
@ActiveProfiles("dev") @ActiveProfiles("dev")
@@ -28,23 +29,27 @@ class loginControllerTest {
} }
@Test @Test
public void testSmsVerification(){ public void testSmsVerification() {
try { try {
loginController.smsVerification("手机号码"); SmsVerificationDTO smsVerificationDTO = new SmsVerificationDTO();
}catch (Exception e){ smsVerificationDTO.setPhone("手机号码");
smsVerificationDTO.setCaptchaId("123456");
smsVerificationDTO.setCaptcha("123456");
loginController.smsVerification(smsVerificationDTO);
} catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
} }
@Test @Test
public void testRetrievePassword(){ public void testRetrievePassword() {
try { try {
RetrievePasswordDTO retrievePasswordDTO = new RetrievePasswordDTO(); RetrievePasswordDTO retrievePasswordDTO = new RetrievePasswordDTO();
retrievePasswordDTO.setCode("123456"); retrievePasswordDTO.setCode("123456");
retrievePasswordDTO.setPhone("手机号码"); retrievePasswordDTO.setPhone("手机号码");
retrievePasswordDTO.setPassword("密码"); retrievePasswordDTO.setPassword("密码");
loginController.retrievePassword(retrievePasswordDTO); loginController.retrievePassword(retrievePasswordDTO);
}catch (Exception e){ } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }