提交 af3afc72 编写于 作者: JEECG低代码平台's avatar JEECG低代码平台

删除不需要的底层工具包

上级 63c3dd26
package org.jeecg.common.util.jsonschema;
import lombok.Data;
/**
* 列 配置基本信息
*/
@Data
public class BaseColumn {
/**
* 列配置 描述 -对应数据库字段描述
*/
private String title;
/**
* 列配置 名称 -对应数据库字段名
*/
private String field;
public BaseColumn(){}
public BaseColumn(String title,String field){
this.title = title;
this.field = field;
}
}
package org.jeecg.common.util.jsonschema;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.system.vo.DictModel;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 验证通用属性
*/
public abstract class CommonProperty implements Serializable{
private static final long serialVersionUID = -426159949502493187L;
protected String key;
/**
* <p>此关键字的值必须是字符串或数组。如果它是一个数组,那么数组的元素必须是字符串,并且必须是唯一的。
* <p>字符串值必须是六种基本类型之一(“null”,“boolean”,“object”,“array”,“number”或“string”),或“integer”,它匹配任何数字,零分数部分。
* <p>当且仅当实例位于为此关键字列出的任何集合中时,实例才会验证。
*
*/
protected String type;
/**
* 对应JsonSchema的enum
* <p>该关键字的值必须是一个数组。这个数组应该至少有一个元素。数组中的元素应该是唯一的。如果实例的值等于此关键字的数组值中的某个元素,则实例将对此关键字成功验证。
* 数组中的元素可以是任何值,包括null
*
* {
* "type": "string",
* "enum": ["1", "2", "3"] 需要的话可以通过这个include转一下
* }
*/
protected List<DictModel> include;
/**
* 对应JsonSchema的const
* <p>此关键字的值可以是任何类型,包括null。
* 如果实例的值等于关键字的值,则实例将针对此关键字成功验证。
*/
protected Object constant;
//三个自定义 属性
protected String view;// 展示类型
protected String title;//数据库字段备注
protected Integer order;//字段显示排序
protected boolean disabled;//是否禁用
protected String defVal; // 字段默认值
protected String fieldExtendJson;//扩展参数
protected Integer dbPointLength;//小数点
public String getDefVal() {
return defVal;
}
public void setDefVal(String defVal) {
this.defVal = defVal;
}
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
public String getView() {
return view;
}
public void setView(String view) {
this.view = view;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<DictModel> getInclude() {
return include;
}
public void setInclude(List<DictModel> include) {
this.include = include;
}
public Object getConstant() {
return constant;
}
public void setConstant(Object constant) {
this.constant = constant;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public String getFieldExtendJson() {
return fieldExtendJson;
}
public void setFieldExtendJson(String fieldExtendJson) {
this.fieldExtendJson = fieldExtendJson;
}
public Integer getDbPointLength() {
return dbPointLength;
}
public void setDbPointLength(Integer dbPointLength) {
this.dbPointLength = dbPointLength;
}
/**
* 返回一个map有两个key
* <P>key ---> Property JSON的key
* <P>prop --> JSON object
* @return
*/
public abstract Map<String,Object> getPropertyJson();
public JSONObject getCommonJson() {
JSONObject json = new JSONObject();
json.put("type", type);
if(include!=null && include.size()>0) {
json.put("enum", include);
}
if(constant!=null) {
json.put("const", constant);
}
if(title!=null) {
json.put("title", title);
}
if(order!=null) {
json.put("order", order);
}
if(view==null) {
json.put("view", "input");
}else {
json.put("view", view);
}
if(disabled) {
String str = "{\"widgetattrs\":{\"disabled\":true}}";
JSONObject ui = JSONObject.parseObject(str);
json.put("ui", ui);
}
if (defVal!=null && defVal.length()>0) {
json.put("defVal", defVal);
}
if(fieldExtendJson != null){
json.put("fieldExtendJson", fieldExtendJson);
}
if(dbPointLength !=null ) {
json.put("dbPointLength", dbPointLength);
}
return json;
}
}
package org.jeecg.common.util.jsonschema;
import java.io.Serializable;
import java.util.List;
/**
* JsonSchema 模式类
* < http://json-schema.org/draft-07/schema# >
*/
public class JsonSchemaDescrip implements Serializable{
/**
*
*/
private static final long serialVersionUID = 7682073117441544718L;
private String $schema = "http://json-schema.org/draft-07/schema#";
/**
* 用它给我们的模式提供了标题。
*/
private String title;
/**
* 关于模式的描述。
*/
private String description;
/**
*type 关键字在我们的 JSON 数据上定义了第一个约束:必须是一个 JSON 对象。 可以直接设置成object
*/
private String type;
private List<String> required;
public List<String> getRequired() {
return required;
}
public void setRequired(List<String> required) {
this.required = required;
}
public String get$schema() {
return $schema;
}
public void set$schema(String $schema) {
this.$schema = $schema;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public JsonSchemaDescrip() {}
public JsonSchemaDescrip(List<String> required) {
this.description="我是一个jsonschema description";
this.title="我是一个jsonschema title";
this.type="object";
this.required = required;
}
}
package org.jeecg.common.util.jsonschema;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class JsonschemaUtil {
/**
* 生成JsonSchema
*
* @param descrip
* @param propertyList
* @return
*/
public static JSONObject getJsonSchema(JsonSchemaDescrip descrip, List<CommonProperty> propertyList) {
JSONObject obj = new JSONObject();
obj.put("$schema", descrip.get$schema());
obj.put("type", descrip.getType());
obj.put("title", descrip.getTitle());
List<String> requiredArr = descrip.getRequired();
obj.put("required", requiredArr);
JSONObject properties = new JSONObject();
for (CommonProperty commonProperty : propertyList) {
Map<String, Object> map = commonProperty.getPropertyJson();
properties.put(map.get("key").toString(), map.get("prop"));
}
obj.put("properties", properties);
//鬼知道这里为什么报错 org.jeecg.modules.system.model.DictModel cannot be cast to org.jeecg.modules.system.model.DictModel
//log.info("---JSONSchema--->"+obj.toJSONString());
return obj;
}
/**
* 生成JsonSchema 用于子对象
* @param title 子对象描述
* @param requiredArr 子对象必填属性名集合
* @param propertyList 子对象属性集合
* @return
*/
public static JSONObject getSubJsonSchema(String title,List<String> requiredArr,List<CommonProperty> propertyList) {
JSONObject obj = new JSONObject();
obj.put("type", "object");
obj.put("view", "tab");
obj.put("title", title);
if(requiredArr==null) {
requiredArr = new ArrayList<String>();
}
obj.put("required", requiredArr);
JSONObject properties = new JSONObject();
for (CommonProperty commonProperty : propertyList) {
Map<String, Object> map = commonProperty.getPropertyJson();
properties.put(map.get("key").toString(), map.get("prop"));
}
obj.put("properties", properties);
//log.info("---JSONSchema--->"+obj.toString());
return obj;
}
}
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.Map;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
/**
* 字典属性
* @author 86729
*
*/
public class DictProperty extends CommonProperty {
private static final long serialVersionUID = 3786503639885610767L;
//字典三属性
private String dictCode;
private String dictTable;
private String dictText;
public String getDictCode() {
return dictCode;
}
public void setDictCode(String dictCode) {
this.dictCode = dictCode;
}
public String getDictTable() {
return dictTable;
}
public void setDictTable(String dictTable) {
this.dictTable = dictTable;
}
public String getDictText() {
return dictText;
}
public void setDictText(String dictText) {
this.dictText = dictText;
}
public DictProperty() {}
/**
* 构造器
*/
public DictProperty(String key,String title,String dictTable,String dictCode,String dictText) {
this.type = "string";
this.view = "sel_search";
this.key = key;
this.title = title;
this.dictCode = dictCode;
this.dictTable= dictTable;
this.dictText= dictText;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
if(dictCode!=null) {
prop.put("dictCode",dictCode);
}
if(dictTable!=null) {
prop.put("dictTable",dictTable);
}
if(dictText!=null) {
prop.put("dictText",dictText);
}
map.put("prop",prop);
return map;
}
//TODO 重构问题:数据字典 只是字符串类的还是有存储的数值类型?只有字符串请跳过这个 只改前端
}
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.Map;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
/**
* 字典属性
* @author 86729
*
*/
public class HiddenProperty extends CommonProperty {
private static final long serialVersionUID = -8939298551502162479L;
public HiddenProperty() {}
public HiddenProperty(String key,String title) {
this.type = "string";
this.view = "hidden";
this.key = key;
this.title = title;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
prop.put("hidden",true);
map.put("prop",prop);
return map;
}
}
package org.jeecg.common.util.jsonschema.validate;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.jsonschema.BaseColumn;
import org.jeecg.common.util.jsonschema.CommonProperty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 级联下拉
*/
public class LinkDownProperty extends CommonProperty {
/**
* 配置信息
*/
String dictTable;
/**
* 级联下拉组件 的其他级联列
*/
List<BaseColumn> otherColumns;
public String getDictTable(){
return this.dictTable;
}
public void setDictTable(String dictTable){
this.dictTable = dictTable;
}
public List<BaseColumn> getOtherColumns(){
return this.otherColumns;
}
public void setOtherColumns(List<BaseColumn> otherColumns){
this.otherColumns = otherColumns;
}
public LinkDownProperty() {}
/**
* 构造器
*/
public LinkDownProperty(String key,String title,String dictTable) {
this.type = "string";
this.view = "link_down";
this.key = key;
this.title = title;
this.dictTable= dictTable;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String, Object> map = new HashMap<>();
map.put("key", getKey());
JSONObject prop = getCommonJson();
JSONObject temp = JSONObject.parseObject(this.dictTable);
prop.put("config", temp);
prop.put("others", otherColumns);
map.put("prop", prop);
return map;
}
}
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
public class NumberProperty extends CommonProperty {
private static final long serialVersionUID = -558615331436437200L;
/**
* 倍数
* 验证实例是否为此数值的倍数
* “multipleOf”的值必须是一个数字,严格大于0。
*/
private Integer multipleOf;
/**
* 小于等于
* “maximum”的值必须是一个数字,表示数字实例的包含上限。
* 如果实例是数字,则仅当实例小于或等于“最大”时,此关键字才会生效。
*/
private Integer maxinum;
/**
* 小于
* “exclusiveMaximum”的值必须是数字,表示数字实例的独占上限。
* 如果实例是数字,则实例仅在其值严格小于(不等于)“exclusiveMaximum”时才有效。
*/
private Integer exclusiveMaximum;
/**
* 大于等于
*/
private Integer minimum;
/**
* 大于等于
*/
private Integer exclusiveMinimum;
private String pattern;
public Integer getMultipleOf() {
return multipleOf;
}
public void setMultipleOf(Integer multipleOf) {
this.multipleOf = multipleOf;
}
public Integer getMaxinum() {
return maxinum;
}
public void setMaxinum(Integer maxinum) {
this.maxinum = maxinum;
}
public Integer getExclusiveMaximum() {
return exclusiveMaximum;
}
public void setExclusiveMaximum(Integer exclusiveMaximum) {
this.exclusiveMaximum = exclusiveMaximum;
}
public Integer getMinimum() {
return minimum;
}
public void setMinimum(Integer minimum) {
this.minimum = minimum;
}
public Integer getExclusiveMinimum() {
return exclusiveMinimum;
}
public void setExclusiveMinimum(Integer exclusiveMinimum) {
this.exclusiveMinimum = exclusiveMinimum;
}
public String getPattern() {
return pattern;
}
public void setPattern(String pattern) {
this.pattern = pattern;
}
public NumberProperty() {}
/**
* 构造器
* @param key 字段名
* @param title 字段备注
* @param type number和integer
*/
public NumberProperty(String key,String title,String type) {
this.key = key;
this.type = type;
this.title = title;
this.view = "number";
}
/**
* 列表类型的走这个构造器 字典里存储的都是字符串 没法走这个构造器
* @param key
* @param type
* @param view list-checkbox-radio
* @param include
*/
public NumberProperty(String key,String title,String view,List<DictModel> include) {
this.type = "integer";
this.key = key;
this.view = view;
this.title = title;
this.include = include;
}
@Override
public Map<String,Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
if(multipleOf!=null) {
prop.put("multipleOf",multipleOf);
}
if(maxinum!=null) {
prop.put("maxinum",maxinum);
}
if(exclusiveMaximum!=null) {
prop.put("exclusiveMaximum",exclusiveMaximum);
}
if(minimum!=null) {
prop.put("minimum",minimum);
}
if(exclusiveMinimum!=null) {
prop.put("exclusiveMinimum",exclusiveMinimum);
}
if(pattern!=null) {
prop.put("pattern",pattern);
}
map.put("prop",prop);
return map;
}
}
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
public class PopupProperty extends CommonProperty {
private static final long serialVersionUID = -3200493311633999539L;
private String code;
private String destFields;
private String orgFields;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDestFields() {
return destFields;
}
public void setDestFields(String destFields) {
this.destFields = destFields;
}
public String getOrgFields() {
return orgFields;
}
public void setOrgFields(String orgFields) {
this.orgFields = orgFields;
}
public PopupProperty() {}
public PopupProperty(String key,String title,String code,String destFields,String orgFields) {
this.view = "popup";
this.type = "string";
this.key = key;
this.title = title;
this.code = code;
this.destFields=destFields;
this.orgFields=orgFields;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
if(code!=null) {
prop.put("code",code);
}
if(destFields!=null) {
prop.put("destFields",destFields);
}
if(orgFields!=null) {
prop.put("orgFields",orgFields);
}
map.put("prop",prop);
return map;
}
}
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
public class StringProperty extends CommonProperty {
private static final long serialVersionUID = -3200493311633999539L;
private Integer maxLength;
private Integer minLength;
/**
* 根据ECMA 262正则表达式方言,该字符串应该是有效的正则表达式。
*/
private String pattern;
/**
* 错误提示信息
*/
private String errorInfo;
public Integer getMaxLength() {
return maxLength;
}
public void setMaxLength(Integer maxLength) {
this.maxLength = maxLength;
}
public Integer getMinLength() {
return minLength;
}
public void setMinLength(Integer minLength) {
this.minLength = minLength;
}
public String getPattern() {
return pattern;
}
public void setPattern(String pattern) {
this.pattern = pattern;
}
public String getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(String errorInfo) {
this.errorInfo = errorInfo;
}
public StringProperty() {}
/**
* 一般字符串类型走这个构造器
* @param key 字段名
* @param title 字段备注
* @param view 展示控件
* @param maxLength 数据库字段最大长度
*/
public StringProperty(String key,String title,String view,Integer maxLength) {
this.maxLength = maxLength;
this.key = key;
this.view = view;
this.title = title;
this.type = "string";
}
/**
* 列表类型的走这个构造器
* @param key 字段名
* @param title 字段备注
* @param view 展示控件 list-checkbox-radio
* @param maxLength 数据库字段最大长度
* @param include 数据字典
*/
public StringProperty(String key,String title,String view,Integer maxLength,List<DictModel> include) {
this.maxLength = maxLength;
this.key = key;
this.view = view;
this.title = title;
this.type = "string";
this.include = include;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
if(maxLength!=null) {
prop.put("maxLength",maxLength);
}
if(minLength!=null) {
prop.put("minLength",minLength);
}
if(pattern!=null) {
prop.put("pattern",pattern);
}
if(errorInfo!=null) {
prop.put("errorInfo",errorInfo);
}
map.put("prop",prop);
return map;
}
}
package org.jeecg.common.util.jsonschema.validate;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.jsonschema.CommonProperty;
import java.util.HashMap;
import java.util.Map;
/**
* 开关 属性
*/
public class SwitchProperty extends CommonProperty {
//扩展参数配置信息
private String extendStr;
public SwitchProperty() {}
/**
* 构造器
*/
public SwitchProperty(String key, String title, String extendStr) {
this.type = "string";
this.view = "switch";
this.key = key;
this.title = title;
this.extendStr = extendStr;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
JSONArray array = new JSONArray();
if(extendStr!=null) {
array = JSONArray.parseArray(extendStr);
prop.put("extendOption",array);
}
map.put("prop",prop);
return map;
}
//TODO 重构问题:数据字典 只是字符串类的还是有存储的数值类型?只有字符串请跳过这个 只改前端
}
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.Map;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
/**
* 字典属性
* @author 86729
*
*/
public class TreeSelectProperty extends CommonProperty {
private static final long serialVersionUID = 3786503639885610767L;
private String dict;//表名,文本,id
private String pidField;//父级字段 默认pid
private String pidValue;//父级节点的值 暂时没用到 默认为0
private String hasChildField;
private String textField;//树形下拉保存text值的字段名
/**
* 是不是pid 组件 1是 0否
*/
private Integer pidComponent = 0;
public String getDict() {
return dict;
}
public void setDict(String dict) {
this.dict = dict;
}
public String getPidField() {
return pidField;
}
public void setPidField(String pidField) {
this.pidField = pidField;
}
public String getPidValue() {
return pidValue;
}
public void setPidValue(String pidValue) {
this.pidValue = pidValue;
}
public String getHasChildField() {
return hasChildField;
}
public void setHasChildField(String hasChildField) {
this.hasChildField = hasChildField;
}
public TreeSelectProperty() {}
public String getTextField() {
return textField;
}
public void setTextField(String textField) {
this.textField = textField;
}
public Integer getPidComponent() {
return pidComponent;
}
public void setPidComponent(Integer pidComponent) {
this.pidComponent = pidComponent;
}
/**
* 构造器 构造普通树形下拉
*/
public TreeSelectProperty(String key,String title,String dict,String pidField,String pidValue) {
this.type = "string";
this.view = "sel_tree";
this.key = key;
this.title = title;
this.dict = dict;
this.pidField= pidField;
this.pidValue= pidValue;
}
/**
* 分类字典下拉专用
* @param key
* @param title
* @param pidValue
*/
public TreeSelectProperty(String key,String title,String pidValue) {
this.type = "string";
this.view = "cat_tree";
this.key = key;
this.title = title;
this.pidValue = pidValue;
}
/**
* 分类字典 支持存储text 下拉专用
* @param key
* @param title
* @param pidValue
* @param textField
*/
public TreeSelectProperty(String key,String title,String pidValue,String textField) {
this(key,title,pidValue);
this.textField = textField;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
if(dict!=null) {
prop.put("dict",dict);
}
if(pidField!=null) {
prop.put("pidField",pidField);
}
if(pidValue!=null) {
prop.put("pidValue",pidValue);
}
if(textField!=null) {
prop.put("textField",textField);
}
if(hasChildField!=null) {
prop.put("hasChildField",hasChildField);
}
if(pidComponent!=null) {
prop.put("pidComponent",pidComponent);
}
map.put("prop",prop);
return map;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册