Compare commits

...

2 Commits

Author SHA1 Message Date
37c0ac035e 【改进】统一异常捕获 2025-11-25 17:42:12 +08:00
977ca260da 【优化】忘记密码 2025-11-25 17:41:47 +08:00
2 changed files with 5 additions and 4 deletions

View File

@@ -50,10 +50,10 @@ public class GlobalExceptionHandler {
* 处理其他异常 * 处理其他异常
*/ */
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public Result<String> handleException(Exception e) { public Result<String> handleException(Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return Result.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), return Result.error(HttpStatus.INTERNAL_SERVER_ERROR.value(),
I18nUtil.getMessage("error.server.internal", e.getMessage())); e.getMessage());
} }
} }

View File

@@ -264,8 +264,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
} }
String codeKey = String.format("verify_code:%s:%s", "forget", request.getAccount()); String codeKey = String.format("verify_code:%s:%s", "forget", request.getAccount());
String checkCode = redisUtil.get(codeKey).toString(); Object checkCode = redisUtil.get(codeKey);
if(!checkCode.equalsIgnoreCase(request.getVerificationCode())) {
if(checkCode == null || !request.getVerificationCode().equalsIgnoreCase(checkCode.toString())) {
throw new RuntimeException(I18nUtil.getMessage("error.verify.code.invalid")); throw new RuntimeException(I18nUtil.getMessage("error.verify.code.invalid"));
} }