refactor: 用 @Email 和 @Mobile 注解替换了部分验证,提高了代码可读性,修改了多处错误提示信息,使其更加友好

This commit is contained in:
2025-03-27 21:21:53 +08:00
parent c130f9c0bb
commit 19639c946a
26 changed files with 60 additions and 65 deletions

View File

@@ -37,6 +37,6 @@ public class CommonStatusUpdateReq implements Serializable {
* 状态
*/
@Schema(description = "状态", example = "1")
@NotNull(message = "状态非法")
@NotNull(message = "状态无效")
private DisEnableStatusEnum status;
}

View File

@@ -67,7 +67,7 @@ public abstract class AbstractLoginHandler<T extends LoginReq> implements LoginH
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
protected static final String CAPTCHA_EXPIRED = "验证码已失效";
protected static final String CAPTCHA_ERROR = "验证码错误";
protected static final String CAPTCHA_ERROR = "验证码不正确";
protected static final String CLIENT_ID = "clientId";
@Override

View File

@@ -63,7 +63,7 @@ public class AccountLoginHandler extends AbstractLoginHandler<AccountLoginReq> {
boolean isError = ObjectUtil.isNull(user) || !passwordEncoder.matches(rawPassword, user.getPassword());
// 检查账号锁定状态
this.checkUserLocked(req.getUsername(), request, isError);
ValidationUtils.throwIf(isError, "用户名或密码错误");
ValidationUtils.throwIf(isError, "用户名或密码不正确");
// 检查用户状态
super.checkUserStatus(user);
// 执行认证
@@ -97,7 +97,7 @@ public class AccountLoginHandler extends AbstractLoginHandler<AccountLoginReq> {
*
* @param username 用户名
* @param request 请求对象
* @param isError 是否登录错误
* @param isError 是否登录失败
*/
private void checkUserLocked(String username, HttpServletRequest request, boolean isError) {
// 不锁定

View File

@@ -16,10 +16,9 @@
package top.continew.admin.auth.model.req;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@@ -43,7 +42,7 @@ public class EmailLoginReq extends LoginReq {
*/
@Schema(description = "邮箱", example = "123456789@qq.com")
@NotBlank(message = "邮箱不能为空")
@Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误")
@Email(message = "邮箱格式不正确")
private String email;
/**
@@ -51,6 +50,6 @@ public class EmailLoginReq extends LoginReq {
*/
@Schema(description = "验证码", example = "888888")
@NotBlank(message = "验证码不能为空")
@Length(max = 6, message = "验证码非法")
@Length(max = 6, message = "验证码无效")
private String captcha;
}

View File

@@ -57,6 +57,6 @@ public class LoginReq implements Serializable {
* 认证类型
*/
@Schema(description = "认证类型", example = "ACCOUNT")
@NotNull(message = "认证类型非法")
@NotNull(message = "认证类型无效")
private AuthTypeEnum authType;
}

View File

@@ -16,12 +16,11 @@
package top.continew.admin.auth.model.req;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.continew.starter.core.validation.constraints.Mobile;
import java.io.Serial;
@@ -43,7 +42,7 @@ public class PhoneLoginReq extends LoginReq {
*/
@Schema(description = "手机号", example = "13811111111")
@NotBlank(message = "手机号不能为空")
@Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误")
@Mobile
private String phone;
/**
@@ -51,6 +50,6 @@ public class PhoneLoginReq extends LoginReq {
*/
@Schema(description = "验证码", example = "888888")
@NotBlank(message = "验证码不能为空")
@Length(max = 6, message = "验证码非法")
@Length(max = 6, message = "验证码无效")
private String captcha;
}

View File

@@ -47,7 +47,7 @@ public enum PasswordPolicyEnum {
/**
* 密码错误锁定阈值
*/
PASSWORD_ERROR_LOCK_COUNT("密码错误锁定阈值取值范围为 %d-%d", SysConstants.NO, 10, "密码错误已达 %d 次,账号锁定 %d 分钟"),
PASSWORD_ERROR_LOCK_COUNT("密码错误锁定阈值取值范围为 %d-%d", SysConstants.NO, 10, "密码不正确已达 %d 次,账号锁定 %d 分钟"),
/**
* 账号锁定时长(分钟)

View File

@@ -51,6 +51,6 @@ public class OptionQuery implements Serializable {
* 类别
*/
@Schema(description = "类别", example = "SITE")
@EnumValue(value = OptionCategoryEnum.class, message = "类别非法")
@EnumValue(value = OptionCategoryEnum.class, message = "类别无效")
private String category;
}

View File

@@ -45,7 +45,7 @@ public class MenuReq implements Serializable {
* 类型
*/
@Schema(description = "类型", example = "2")
@NotNull(message = "类型非法")
@NotNull(message = "类型无效")
private MenuTypeEnum type;
/**
@@ -133,6 +133,6 @@ public class MenuReq implements Serializable {
* 状态
*/
@Schema(description = "状态", example = "1")
@NotNull(message = "状态非法")
@NotNull(message = "状态无效")
private DisEnableStatusEnum status;
}

View File

@@ -59,6 +59,6 @@ public class MessageReq implements Serializable {
* 类型
*/
@Schema(description = "类型1系统消息", example = "1")
@NotNull(message = "类型非法")
@NotNull(message = "类型无效")
private MessageTypeEnum type;
}

View File

@@ -64,7 +64,7 @@ public class StorageReq implements Serializable {
* 类型
*/
@Schema(description = "类型", example = "2")
@NotNull(message = "类型非法")
@NotNull(message = "类型无效")
private StorageTypeEnum type;
/**

View File

@@ -52,6 +52,6 @@ public class UserBasicInfoUpdateReq implements Serializable {
* 性别
*/
@Schema(description = "性别", example = "1")
@NotNull(message = "性别非法")
@NotNull(message = "性别无效")
private GenderEnum gender;
}

View File

@@ -16,10 +16,9 @@
package top.continew.admin.system.model.req.user;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@@ -44,7 +43,7 @@ public class UserEmailUpdateRequest implements Serializable {
*/
@Schema(description = "新邮箱", example = "123456789@qq.com")
@NotBlank(message = "新邮箱不能为空")
@Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误")
@Email(message = "邮箱格式不正确")
private String email;
/**
@@ -52,7 +51,7 @@ public class UserEmailUpdateRequest implements Serializable {
*/
@Schema(description = "验证码", example = "888888")
@NotBlank(message = "验证码不能为空")
@Length(max = 6, message = "验证码非法")
@Length(max = 6, message = "验证码无效")
private String captcha;
/**

View File

@@ -16,13 +16,14 @@
package top.continew.admin.system.model.req.user;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.continew.admin.common.constant.RegexConstants;
import top.continew.starter.core.validation.constraints.Mobile;
import top.continew.starter.extension.crud.validation.CrudValidationGroup;
import java.io.Serial;
@@ -81,14 +82,14 @@ public class UserImportRowReq implements Serializable {
/**
* 邮箱
*/
@Pattern(regexp = "^$|" + RegexPool.EMAIL, message = "邮箱格式错误")
@Length(max = 255, message = "邮箱长度不能超过 {max} 个字符")
@Email(message = "邮箱格式不正确")
private String email;
/**
* 手机号码
*/
@Pattern(regexp = "^$|" + RegexPool.MOBILE, message = "手机号码格式错误")
@Mobile
private String phone;
/**

View File

@@ -16,12 +16,11 @@
package top.continew.admin.system.model.req.user;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.continew.starter.core.validation.constraints.Mobile;
import java.io.Serial;
import java.io.Serializable;
@@ -44,7 +43,7 @@ public class UserPhoneUpdateReq implements Serializable {
*/
@Schema(description = "新手机号", example = "13811111111")
@NotBlank(message = "新手机号不能为空")
@Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误")
@Mobile(message = "手机号格式不正确")
private String phone;
/**
@@ -52,7 +51,7 @@ public class UserPhoneUpdateReq implements Serializable {
*/
@Schema(description = "验证码", example = "888888")
@NotBlank(message = "验证码不能为空")
@Length(max = 6, message = "验证码非法")
@Length(max = 6, message = "验证码无效")
private String captcha;
/**

View File

@@ -16,7 +16,6 @@
package top.continew.admin.system.model.req.user;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
@@ -24,6 +23,7 @@ import org.hibernate.validator.constraints.Length;
import top.continew.admin.common.constant.RegexConstants;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.admin.common.enums.GenderEnum;
import top.continew.starter.core.validation.constraints.Mobile;
import top.continew.starter.extension.crud.validation.CrudValidationGroup;
import java.io.Serial;
@@ -70,23 +70,22 @@ public class UserReq implements Serializable {
* 邮箱
*/
@Schema(description = "邮箱", example = "123456789@qq.com")
@Pattern(regexp = "^$|" + RegexPool.EMAIL, message = "邮箱格式错误")
@Length(max = 255, message = "邮箱长度不能超过 {max} 个字符")
@Email
@Email(message = "邮箱格式不正确")
private String email;
/**
* 手机号
* 手机号
*/
@Schema(description = "手机号", example = "13811111111")
@Pattern(regexp = "^$|" + RegexPool.MOBILE, message = "手机号码格式错误")
@Schema(description = "手机号", example = "13811111111")
@Mobile
private String phone;
/**
* 性别
*/
@Schema(description = "性别", example = "1")
@NotNull(message = "性别非法")
@NotNull(message = "性别无效")
private GenderEnum gender;
/**

View File

@@ -134,7 +134,7 @@ public class OptionServiceImpl implements OptionService {
.one();
CheckUtils.throwIfNull(option, "参数 [{}] 不存在", code);
value = StrUtil.nullToDefault(option.getValue(), option.getDefaultValue());
CheckUtils.throwIfBlank(value, "参数 [{}] 数据错误", code);
CheckUtils.throwIfBlank(value, "参数 [{}] 数据不正确", code);
RedisUtils.set(CacheConstants.OPTION_KEY_PREFIX + code, value);
return mapper.apply(value);
}

View File

@@ -164,7 +164,7 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
public void load(StorageReq req) {
CopyOnWriteArrayList<FileStorage> fileStorageList = fileStorageService.getFileStorageList();
String domain = req.getDomain();
ValidationUtils.throwIf(!URLUtils.isHttpUrl(domain), "域名格式错误");
ValidationUtils.throwIf(!URLUtils.isHttpUrl(domain), "域名格式不正确");
String bucketName = req.getBucketName();
StorageTypeEnum type = req.getType();
if (StorageTypeEnum.LOCAL.equals(type)) {

View File

@@ -253,11 +253,11 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
}
// 总计行数
userImportResp.setTotalRows(importRowList.size());
CheckUtils.throwIfEmpty(importRowList, "数据文件格式错误");
CheckUtils.throwIfEmpty(importRowList, "数据文件格式不正确");
// 有效行数:过滤无效数据
List<UserImportRowReq> validRowList = this.filterImportData(importRowList);
userImportResp.setValidRows(validRowList.size());
CheckUtils.throwIfEmpty(validRowList, "数据文件格式错误");
CheckUtils.throwIfEmpty(validRowList, "数据文件格式不正确");
// 检测表格内数据是否合法
Set<String> seenEmails = new HashSet<>();
@@ -271,14 +271,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
.anyMatch(phone -> phone != null && !seenPhones.add(phone));
CheckUtils.throwIf(hasDuplicatePhone, "存在重复手机,请检测数据");
// 校验是否存在错误角色
// 校验是否存在无效角色
List<String> roleNames = validRowList.stream().map(UserImportRowReq::getRoleName).distinct().toList();
int existRoleCount = roleService.countByNames(roleNames);
CheckUtils.throwIf(existRoleCount < roleNames.size(), "存在错误角色,请检查数据");
// 校验是否存在错误部门
CheckUtils.throwIf(existRoleCount < roleNames.size(), "存在无效角色,请检查数据");
// 校验是否存在无效部门
List<String> deptNames = validRowList.stream().map(UserImportRowReq::getDeptName).distinct().toList();
int existDeptCount = deptService.countByNames(deptNames);
CheckUtils.throwIf(existDeptCount < deptNames.size(), "存在错误部门,请检查数据");
CheckUtils.throwIf(existDeptCount < deptNames.size(), "存在无效部门,请检查数据");
// 查询重复用户
userImportResp
@@ -425,7 +425,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
UserDO user = super.getById(id);
String password = user.getPassword();
if (StrUtil.isNotBlank(password)) {
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, password), "当前密码错误");
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, password), "当前密码不正确");
}
// 校验密码合法性
int passwordRepetitionTimes = this.checkPassword(newPassword, user);
@@ -444,7 +444,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
@Override
public void updatePhone(String newPhone, String oldPassword, Long id) {
UserDO user = super.getById(id);
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, user.getPassword()), "当前密码错误");
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, user.getPassword()), "当前密码不正确");
CheckUtils.throwIf(this.isPhoneExists(newPhone, id), "手机号已绑定其他账号,请更换其他手机号");
CheckUtils.throwIfEqual(newPhone, user.getPhone(), "新手机号不能与当前手机号相同");
// 更新手机号
@@ -454,7 +454,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
@Override
public void updateEmail(String newEmail, String oldPassword, Long id) {
UserDO user = super.getById(id);
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, user.getPassword()), "当前密码错误");
CheckUtils.throwIf(!passwordEncoder.matches(oldPassword, user.getPassword()), "当前密码不正确");
CheckUtils.throwIf(this.isEmailExists(newEmail, id), "邮箱已绑定其他账号,请更换其他邮箱");
CheckUtils.throwIfEqual(newEmail, user.getEmail(), "新邮箱不能与当前邮箱相同");
// 更新邮箱

View File

@@ -76,7 +76,7 @@ public class GenConfigDO implements Serializable {
*/
@Schema(description = "包名称", example = "top.continew.admin.system")
@NotBlank(message = "包名称不能为空")
@Pattern(regexp = RegexConstants.PACKAGE_NAME, message = "包名称格式错误")
@Pattern(regexp = RegexConstants.PACKAGE_NAME, message = "包名称格式不正确")
@Length(max = 60, message = "包名称不能超过 {max} 个字符")
private String packageName;

View File

@@ -54,7 +54,7 @@ public class OpenApiSignTemplate extends SaSignTemplate {
ValidationUtils.throwIfBlank(signValue, "sign不能为空");
ValidationUtils.throwIfBlank(accessKeyValue, "accessKey不能为空");
AppDO app = appService.getByAccessKey(accessKeyValue);
ValidationUtils.throwIfNull(app, "accessKey非法");
ValidationUtils.throwIfNull(app, "accessKey无效");
ValidationUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, app.getStatus(), "应用已被禁用, 请联系管理员");
ValidationUtils.throwIf(app.isExpired(), "应用已过期, 请联系管理员");

View File

@@ -65,7 +65,7 @@ public class JobReq implements Serializable {
* 触发类型
*/
@Schema(description = "触发类型", example = "2")
@NotNull(message = "触发类型非法")
@NotNull(message = "触发类型无效")
private JobTriggerTypeEnum triggerType;
/**
@@ -85,7 +85,7 @@ public class JobReq implements Serializable {
* 任务类型
*/
@Schema(description = "任务类型", example = "1")
@NotNull(message = "任务类型非法")
@NotNull(message = "任务类型无效")
private JobTaskTypeEnum taskType;
/**
@@ -111,14 +111,14 @@ public class JobReq implements Serializable {
* 路由策略
*/
@Schema(description = "路由策略", example = "4")
@NotNull(message = "路由策略非法")
@NotNull(message = "路由策略无效")
private JobRouteStrategyEnum routeKey;
/**
* 阻塞策略
*/
@Schema(description = "阻塞策略", example = "1")
@NotNull(message = "阻塞策略非法")
@NotNull(message = "阻塞策略无效")
private JobBlockStrategyEnum blockStrategy;
/**

View File

@@ -42,7 +42,7 @@ public class JobStatusReq implements Serializable {
* 任务状态
*/
@Schema(description = "任务状态", example = "1")
@NotNull(message = "任务状态非法")
@NotNull(message = "任务状态无效")
private JobStatusEnum jobStatus;
/**

View File

@@ -19,7 +19,6 @@ package top.continew.admin.controller.common;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.lang.RegexPool;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
@@ -34,8 +33,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.mail.MessagingException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.RequiredArgsConstructor;
import org.dromara.sms4j.api.SmsBlend;
import org.dromara.sms4j.api.entity.SmsResponse;
@@ -56,6 +55,7 @@ import top.continew.starter.core.autoconfigure.project.ProjectProperties;
import top.continew.starter.core.util.TemplateUtils;
import top.continew.starter.core.validation.CheckUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.core.validation.constraints.Mobile;
import top.continew.starter.log.annotation.Log;
import top.continew.starter.messaging.mail.util.MailUtils;
import top.continew.starter.ratelimiter.annotation.RateLimiter;
@@ -146,7 +146,7 @@ public class CaptchaController {
@RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "DAY'", key = "#email + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.mail.templatePath')", rate = 20, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
@RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#email", rate = 100, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
@RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#email", rate = 30, interval = 1, unit = TimeUnit.MINUTES, type = LimitType.IP, message = "获取验证码操作太频繁,请稍后再试")})
public R getMailCaptcha(@NotBlank(message = "邮箱不能为空") @Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误") String email,
public R getMailCaptcha(@NotBlank(message = "邮箱不能为空") @Email(message = "邮箱格式不正确") String email,
CaptchaVO captchaReq) throws MessagingException {
// 行为验证码校验
ResponseModel verificationRes = behaviorCaptchaService.verification(captchaReq);
@@ -193,8 +193,7 @@ public class CaptchaController {
@RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "DAY'", key = "#phone + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.sms.templateId')", rate = 20, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
@RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#phone", rate = 100, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
@RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#phone", rate = 30, interval = 1, unit = TimeUnit.MINUTES, type = LimitType.IP, message = "获取验证码操作太频繁,请稍后再试")})
public R getSmsCaptcha(@NotBlank(message = "手机号不能为空") @Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误") String phone,
CaptchaVO captchaReq) {
public R getSmsCaptcha(@NotBlank(message = "手机号不能为空") @Mobile String phone, CaptchaVO captchaReq) {
// 行为验证码校验
ResponseModel verificationRes = behaviorCaptchaService.verification(captchaReq);
ValidationUtils.throwIfNotEqual(verificationRes.getRepCode(), RepCodeEnum.SUCCESS.getCode(), verificationRes

View File

@@ -68,10 +68,10 @@ public class MenuController extends BaseController<MenuService, MenuResp, MenuRe
Boolean isExternal = ObjectUtil.defaultIfNull(req.getIsExternal(), false);
String path = req.getPath();
ValidationUtils.throwIf(Boolean.TRUE.equals(isExternal) && !URLUtils
.isHttpUrl(path), "路由地址格式错误,请以 http:// 或 https:// 开头");
.isHttpUrl(path), "路由地址格式不正确,请以 http:// 或 https:// 开头");
// 非外链菜单参数修正
if (Boolean.FALSE.equals(isExternal)) {
ValidationUtils.throwIf(URLUtils.isHttpUrl(path), "路由地址格式错误");
ValidationUtils.throwIf(URLUtils.isHttpUrl(path), "路由地址格式不正确");
req.setPath(StrUtil.isBlank(path) ? path : StrUtil.prependIfMissing(path, StringConstants.SLASH));
req.setName(StrUtil.removePrefix(req.getName(), StringConstants.SLASH));
req.setComponent(StrUtil.removePrefix(req.getComponent(), StringConstants.SLASH));

View File

@@ -104,7 +104,7 @@ public class UserCenterController {
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + updateReq.getPhone();
String captcha = RedisUtils.get(captchaKey);
ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
ValidationUtils.throwIfNotEqualIgnoreCase(updateReq.getCaptcha(), captcha, "验证码错误");
ValidationUtils.throwIfNotEqualIgnoreCase(updateReq.getCaptcha(), captcha, "验证码不正确");
RedisUtils.delete(captchaKey);
userService.updatePhone(updateReq.getPhone(), rawOldPassword, UserContextHolder.getUserId());
}
@@ -118,7 +118,7 @@ public class UserCenterController {
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + updateReq.getEmail();
String captcha = RedisUtils.get(captchaKey);
ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
ValidationUtils.throwIfNotEqualIgnoreCase(updateReq.getCaptcha(), captcha, "验证码错误");
ValidationUtils.throwIfNotEqualIgnoreCase(updateReq.getCaptcha(), captcha, "验证码不正确");
RedisUtils.delete(captchaKey);
userService.updateEmail(updateReq.getEmail(), rawOldPassword, UserContextHolder.getUserId());
}