增加支付服务/用户启用状态字典与校验注解
parent
1f70fa3828
commit
920cc7c760
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.common.core.enums;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付服务/用户开启状态
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
*/
|
||||||
|
public enum SysYesNo {
|
||||||
|
YES("Y", "启用"),
|
||||||
|
NO("N", "停用");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
SysYesNo(String code, String info) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode () {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInfo () {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别参数是否是启用状态
|
||||||
|
* @param code 需鉴别参数
|
||||||
|
* @return 如果存在返回结果turn,否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code){
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(SysYesNo::getCode)
|
||||||
|
.anyMatch(c -> c.equals(code));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.common.core.validation;/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: IsSystemYesNoValidator
|
||||||
|
* @Description: 支付服务/客户启用状态校验器
|
||||||
|
* @CreatedDate: 2024/8/5 下午8:00
|
||||||
|
* @FilePath: com.muyu.common.core.validation
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.enums.SysYesNo;
|
||||||
|
import com.muyu.common.core.validation.custom.IsSystemYesNo;
|
||||||
|
import jakarta.validation.ConstraintValidator;
|
||||||
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
import org.bouncycastle.util.IPAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: IsSystemYesNoValidator
|
||||||
|
* @Description: 支付服务/客户启用状态校验器
|
||||||
|
* @CreatedDate: 2024/8/5 下午8:00
|
||||||
|
* @FilePath: com.muyu.common.core.validation
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IsSystemYesNoValidator implements ConstraintValidator<IsSystemYesNo,String> {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||||
|
return SysYesNo.isCode(s);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.common.core.validation.custom;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.IsSystemYesNoValidator;
|
||||||
|
import jakarta.validation.Constraint;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:胡杨
|
||||||
|
* @name: IsSystemYesNo
|
||||||
|
* @Date: 2024/8/5 下午7:57
|
||||||
|
* @Description: com.muyu.common.core.validation.custom
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Constraint(validatedBy = IsSystemYesNoValidator.class)
|
||||||
|
public @interface IsSystemYesNo {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue