fix():增加支付渠道的枚举和校验
parent
b0a2b59e87
commit
31f238746d
|
@ -27,6 +27,11 @@ public enum SysPayType {
|
|||
.anyMatch(s->s.equals(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code查询渠道商的名称
|
||||
* @param code
|
||||
* @return 返回渠道商的名称
|
||||
*/
|
||||
public static String getInfoByCode(String code){
|
||||
return Arrays.stream(values())
|
||||
.filter(s->s.getCode().equals(code))
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.common.core.validation.custom;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = SystemPayTypeValidator.class)
|
||||
public @interface IsSystemPayType {
|
||||
String message() default "数据字典:[支付渠道]-参数不合法";
|
||||
Class<?>[] groups() default {};
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.muyu.common.core.validation.custom;
|
||||
|
||||
import com.muyu.common.core.enums.SysPayType;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
public class SystemPayTypeValidator implements ConstraintValidator<IsSystemPayType,String> {
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
return SysPayType.isCode(value);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue