feat:() 增加系统字典核心
parent
914446febd
commit
ceb79fa55e
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.common.core.enums;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public enum SystemYesNo {
|
||||||
|
YES("Y", "是"),
|
||||||
|
NO("N", "否"),
|
||||||
|
;
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
SystemYesNo(String code, String info) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInfo() {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别Code是否合法
|
||||||
|
*
|
||||||
|
* @param code 传code
|
||||||
|
* @return 如果存在code则返回true, 不存在则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code) {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(SystemYesNo::getCode)
|
||||||
|
.anyMatch(s -> s.equals(code));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.common.core.validation.custom;
|
||||||
|
|
||||||
|
import com.muyu.common.core.enums.SystemYesNo;
|
||||||
|
import jakarta.validation.ConstraintValidator;
|
||||||
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SystemYesNoValidator
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Chen
|
||||||
|
* @Date 2024/8/6 21:01
|
||||||
|
*/
|
||||||
|
public class SystemYesNoValidator implements ConstraintValidator<IsSystemYesNo,String> {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||||
|
return SystemYesNo.isCode(value);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue