新增节点类型字典和字段类型字典
parent
037d48a628
commit
751221b783
|
@ -0,0 +1,75 @@
|
||||||
|
package com.muyu.common.core.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysApiState
|
||||||
|
* @Description: 字段类型字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午7:56
|
||||||
|
* @FilePath: com.muyu.common.core.enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum SysFieldsType {
|
||||||
|
BYTE("Byte",Byte.class, "字节型"),
|
||||||
|
SHORT("Short",Short.class, "短整型"),
|
||||||
|
INTEGER("Integer",Integer.class, "整型"),
|
||||||
|
FLOAT("Float",Float.class, "单精度浮点型"),
|
||||||
|
DOUBLE("Double",Double.class, "双精度浮点型"),
|
||||||
|
LONG("Long",Long.class, "长整型"),
|
||||||
|
CHAR("char",char.class, "字符型"),
|
||||||
|
BOOLEAN("Boolean",Boolean.class, "布尔型"),
|
||||||
|
STRING("String",String.class, "字符串"),
|
||||||
|
LIST("List", List.class, "List集合"),
|
||||||
|
SET("Set", Set.class, "Set集合"),
|
||||||
|
MAP("Map", Map.class, "map集合"),
|
||||||
|
OBJECT("Object",Object.class, "其他");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final Class type;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
SysFieldsType(String code, Class type, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.type = type;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别参数是否是启用状态
|
||||||
|
* @param code 需鉴别参数
|
||||||
|
* @return 如果存在返回结果turn,否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code){
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(SysFieldsType::getCode)
|
||||||
|
.anyMatch(c -> c.equals(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数转换,从编码转换为名称
|
||||||
|
* @param code 编码
|
||||||
|
* @return 名称
|
||||||
|
*/
|
||||||
|
public static Class<?> getTypeByCode(String code){
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.filter(c -> c.getCode().equals(code))
|
||||||
|
.findFirst()
|
||||||
|
.map(SysFieldsType::getType)
|
||||||
|
.orElse(Object.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getNameByCode(String code){
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.filter(c -> c.getCode().equals(code))
|
||||||
|
.findFirst()
|
||||||
|
.map(SysFieldsType::getName)
|
||||||
|
.orElse("-");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.common.core.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysNodeType
|
||||||
|
* @Description: 节点类型枚举
|
||||||
|
* @CreatedDate: 2024/8/29 下午4:46
|
||||||
|
* @FilePath: com.muyu.common.core.enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum SysNodeType {
|
||||||
|
START("start", "开始"),
|
||||||
|
TABLE("table", "表结构"),
|
||||||
|
UNITE("unite", "联合查询"),
|
||||||
|
EXPORTATION("exportation", "数据输出"),
|
||||||
|
END("end", "结束");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
SysNodeType(String code, String info) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别参数是否是枚举的值
|
||||||
|
*
|
||||||
|
* @param code 需鉴别参数
|
||||||
|
* @return 如果存在返回结果turn, 否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code) {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(SysNodeType::getCode)
|
||||||
|
.anyMatch(c -> c.equals(code));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.core.validation;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.enums.*;
|
||||||
|
import com.muyu.common.core.validation.custom.*;
|
||||||
|
import jakarta.validation.ConstraintValidator;
|
||||||
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysFieldsType
|
||||||
|
* @Description: 判断语句
|
||||||
|
* @CreatedDate: 2024/8/29 下午1:54
|
||||||
|
* @FilePath: com.muyu.common.core.validation
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IsSysFieldsTypeValidator implements ConstraintValidator<IsSysFieldsType, String> {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||||
|
return SysFieldsType.isCode(s);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.core.validation;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.enums.*;
|
||||||
|
import com.muyu.common.core.validation.custom.*;
|
||||||
|
import jakarta.validation.ConstraintValidator;
|
||||||
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysNodeType
|
||||||
|
* @Description: 节点类型字典
|
||||||
|
* @CreatedDate: 2024/8/29 下午4:47
|
||||||
|
* @FilePath: com.muyu.common.core.validation
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IsSysNodeTypeValidator implements ConstraintValidator<IsSysNodeType, String> {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||||
|
return SysNodeType.isCode(s);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.common.core.validation.custom;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.*;
|
||||||
|
import jakarta.validation.Constraint;
|
||||||
|
import jakarta.validation.Payload;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysFieldsType
|
||||||
|
* @Description: 字段类型字典判断注释
|
||||||
|
* @CreatedDate: 2024/8/29 下午1:53
|
||||||
|
* @FilePath: com.muyu.common.core.validation.custom
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Constraint(validatedBy = IsSysFieldsTypeValidator.class)
|
||||||
|
public @interface IsSysFieldsType {
|
||||||
|
String message() default "数据字典:[字段类型字典] - 参数不合法";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.common.core.validation.custom;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.*;
|
||||||
|
import jakarta.validation.Constraint;
|
||||||
|
import jakarta.validation.Payload;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysNodeType
|
||||||
|
* @Description: 节点类型字典
|
||||||
|
* @CreatedDate: 2024/8/29 下午4:47
|
||||||
|
* @FilePath: com.muyu.common.core.validation.custom
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Constraint(validatedBy = IsSysNodeTypeValidator.class)
|
||||||
|
public @interface IsSysNodeType {
|
||||||
|
String message() default "数据字典:[节点类型字典] - 参数不合法";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
}
|
Loading…
Reference in New Issue