Compare commits

2 Commits

Author SHA1 Message Date
3bb5397c49 修改 UnsupportedMenuTypeException 的错误码 2023-09-10 16:47:53 +08:00
b69983077a plusone-validator 修改了方法名 2023-09-10 16:47:30 +08:00
5 changed files with 10 additions and 4 deletions

View File

@@ -222,6 +222,10 @@
{
"code": 4040201,
"description": "不支持的 PrincipalType"
},
{
"code": 4040209,
"description": "不支持的菜单类型"
}
]
},

View File

@@ -36,7 +36,7 @@ class LoginCommandValidator extends BaseValidator<LoginCommand> {
private LoginCommandValidator() {
ruleForString(LoginCommand::getAccount)
.notNull("邮箱地址不能为空")
.matchesOr(new Pattern[] { PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE },
.matchesOne(new Pattern[] { PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE },
value -> new RuntimeException('"' + value + "\" 不是邮箱地址或手机号"));
ruleForString(LoginCommand::getPwd)
.notNull("密码不能为空")

View File

@@ -7,11 +7,13 @@ public class UnsupportedMenuTypeException extends InvalidInputException {
@java.io.Serial
private static final long serialVersionUID = -769169844015637730L;
public static final String ERROR_CODE = "4040209";
public UnsupportedMenuTypeException() {
this("不支持的菜单类型");
}
public UnsupportedMenuTypeException(String message) {
super(message);
super(ERROR_CODE, message);
}
}

View File

@@ -16,7 +16,7 @@ public class LoginByOtpCommandValidator extends BaseValidator<LoginByOtpCommand>
ruleForString(LoginByOtpCommand::getPrincipal)
.notNull("输入邮箱地址或手机号")
.notEmpty("输入邮箱地址或手机号")
.matchesOr(List.of(PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE), "输入用户名、邮箱地址或手机号");
.matchesOne(List.of(PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE), "输入用户名、邮箱地址或手机号");
ruleForString(LoginByOtpCommand::getOtp)
.notNull("验证码不能为空")
.notEmpty("验证码不能为空")

View File

@@ -15,7 +15,7 @@ public class LoginByPasswordCommandValidator extends BaseValidator<LoginByPasswo
ruleForString(LoginByPasswordCommand::getPrincipal)
.notNull("输入用户名、邮箱地址或手机号")
.notEmpty("输入用户名、邮箱地址或手机号")
.matchesOr(List.of(PatternConsts.USERNAME, PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE),
.matchesOne(List.of(PatternConsts.USERNAME, PatternConsts.EMAIL, PatternConsts.MOBILE_PHONE),
"输入用户名、邮箱地址或手机号");
ruleForString(LoginByPasswordCommand::getPassword)
.notNull("密码不能为空")