mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、executor微服务错误码整理;2、分堆打包mycat环境封包异常修复;3、订单包裹详情分页新结构适配;4、板材管理移除权限校验;
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ import java.lang.annotation.*;
|
||||
)
|
||||
public @interface Telephone {
|
||||
|
||||
String message() default "电话格式不正确";
|
||||
String message() default "telephone.valid.message";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
|
||||
+13
@@ -3,8 +3,13 @@ package com.cf.imes.framework.common.validation;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
|
||||
import com.cf.imes.framework.common.constants.ResourceBundleConstants;
|
||||
import com.cf.imes.framework.common.util.i18n.core.util.ResourceBundleUtils;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class TelephoneValidator implements ConstraintValidator<Telephone, String> {
|
||||
|
||||
@@ -14,6 +19,14 @@ public class TelephoneValidator implements ConstraintValidator<Telephone, String
|
||||
if (CharSequenceUtil.isEmpty(value)) {
|
||||
return true;
|
||||
}
|
||||
String defaultConstraintMessageTemplate = context.getDefaultConstraintMessageTemplate();
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
defaultConstraintMessageTemplate = ResourceBundleUtils.getMessage(ResourceBundleConstants.MESSAGE_ENUM_PATH, defaultConstraintMessageTemplate, defaultConstraintMessageTemplate, locale);
|
||||
|
||||
// 校验不通过,自定义提示语句(因为,注解上的 value 是枚举类,无法获得枚举类的实际值)
|
||||
context.disableDefaultConstraintViolation(); // 禁用默认的 message 的值
|
||||
context.buildConstraintViolationWithTemplate(defaultConstraintMessageTemplate).addConstraintViolation(); // 重新添加错误提示语句
|
||||
|
||||
// 校验手机
|
||||
return PhoneUtil.isTel(value) || PhoneUtil.isPhone(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user