feat():添加IsSysRuleActivate注解
parent
f80fbe9f70
commit
1e9e3fc181
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>3.6.3</version>
|
||||
<description>
|
||||
cloud-common-core核心模块
|
||||
</description>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.muyu.common.core.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.common.core.enums
|
||||
* @Project:cloud-common-core
|
||||
* @name:SysRuleActivate
|
||||
* @Date:2024/8/25 下午3:14
|
||||
*/
|
||||
public enum SysRuleActivate {
|
||||
START("S","已启动"),UNSTART("U","未启动");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
SysRuleActivate(String code, String info) {
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode () {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo () {
|
||||
return info;
|
||||
}
|
||||
|
||||
public static boolean isCode(String code){
|
||||
return Arrays.stream(values())
|
||||
.map(SysRuleActivate::getCode)
|
||||
.anyMatch(s -> s.equals(code));
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.common.core.validation.custom
|
||||
* @Project:cloud-common-core
|
||||
* @name:IsSysRuleActivate
|
||||
* @Date:2024/8/25 下午3:14
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = IsSysRuleActivateValidation.class)
|
||||
public @interface IsSysRuleActivate {
|
||||
|
||||
String message() default "数据字典:[系统是否] - 参数不合法";
|
||||
Class<?>[] groups() default { };
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.common.core.validation.custom;
|
||||
|
||||
import com.muyu.common.core.enums.SysRuleActivate;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.common.core.validation.custom
|
||||
* @Project:cloud-common-core
|
||||
* @name:SysRuleActivateValidation
|
||||
* @Date:2024/8/25 下午3:15
|
||||
*/
|
||||
public class IsSysRuleActivateValidation implements ConstraintValidator<IsSysRuleActivate, String> {
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
return SysRuleActivate.isCode(value);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue