parent
63c3dd26f5
commit
af3afc7263
@ -1,28 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
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 重构问题:数据字典 只是字符串类的还是有存储的数值类型?只有字符串请跳过这个 只改前端
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
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 重构问题:数据字典 只是字符串类的还是有存储的数值类型?只有字符串请跳过这个 只改前端
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue