提交 c6c2fbb9 编写于 作者: sq3536's avatar sq3536

push

上级 30c6f92b
......@@ -18,20 +18,15 @@
package cn.ibizlab.codegen;
import cn.ibizlab.codegen.ignore.CodegenIgnoreProcessor;
import cn.ibizlab.codegen.lite.DynamicModelStorage;
import cn.ibizlab.codegen.model.CliOption;
import cn.ibizlab.codegen.model.ModelStorage;
import cn.ibizlab.codegen.templating.*;
import cn.ibizlab.codegen.templating.TemplatePathLocator;
import cn.ibizlab.codegen.templating.TemplateProcessor;
import cn.ibizlab.codegen.templating.TemplatingEngineAdapter;
import cn.ibizlab.codegen.templating.*;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
......
package cn.ibizlab.codegen.lite;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import cn.ibizlab.codegen.utils.DataObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
public class DstSystemModel {
/**
* 系统标识
*/
@JSONField(name = "pssystemid")
@JsonProperty("pssystemid")
private String pssystemid;
/**
* 系统名称
*/
@JSONField(name = "pssystemname")
@JsonProperty("pssystemname")
private String pssystemname;
/**
* 结构
*/
@JSONField(name = "sysstructure")
@JsonProperty("sysstructure")
private Map sysstructure;
/**
* 应用
*/
@JSONField(name = "apps")
@JsonProperty("apps")
private List<App> apps;
public DstSystemModel addApp(App app)
{
if(apps==null)
apps=new ArrayList<>();
apps.add(app.setSystemid(this.pssystemid));
return this;
}
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class App{
private String id;
private String label;
private String systemid;
private String fullname;
private String type;
private String group;
private String icon;
private Integer visabled;
private String addr;
}
/**
* 校验
*/
@JSONField(name = "md5check")
@JsonProperty("md5check")
private String md5check;
/**
* 排序
*/
@JSONField(name = "showorder")
@JsonProperty("showorder")
private Integer showorder;
private Map<String, Object> extensionparams;
public DstSystemModel setDynamicModelPath(String dynamic_model_path)
{
if(extensionparams==null)
extensionparams=new HashMap<String, Object>();
extensionparams.put("dynamic_model_path",dynamic_model_path);
return this;
}
@JSONField(serialize = false)
@JsonIgnore
public String getDynamicModelPath()
{
if(extensionparams!=null&&extensionparams.get("dynamic_model_path")!=null)
return extensionparams.get("dynamic_model_path").toString();
return null;
}
public DstSystemModel setLastModify(Long lastModify)
{
if(extensionparams==null)
extensionparams=new HashMap<String, Object>();
extensionparams.put("last_modify",lastModify);
return this;
}
@JSONField(serialize = false)
@JsonIgnore
public Long getLastModify()
{
if(extensionparams!=null&&extensionparams.get("last_modify")!=null)
return DataObject.getLongValue(extensionparams.get("last_modify"),0L);
return 0L;
}
public DstSystemModel fromPath(Path path)
{
try {
if(!Files.exists(path))
throw new IllegalArgumentException("读取文件失败DstSystem:"+path.toString());
JSONObject jo= JSON.parseObject(new String(Files.readAllBytes(path), StandardCharsets.UTF_8));
this.setPssystemid(jo.getString("codeName"));
this.setPssystemname(jo.getString("logicName"));
this.setLastModify(path.toFile().lastModified());
if(jo.containsKey("getAllPSApps"))
{
JSONArray array=jo.getJSONArray("getAllPSApps");
array.forEach(obj->{
JSONObject app=(JSONObject)obj;
String appPath=app.getString("path");
if(!StringUtils.isEmpty(appPath))
{
String[] args=appPath.split("/");
if(args.length==3)
{
String appId=args[1];
this.addApp(new App().setId(appId).setLabel(appId));
}
}
});
}
this.setDynamicModelPath(path.getParent().toAbsolutePath().toString());
} catch (IOException e) {
throw new IllegalArgumentException("读取文件失败DstSystem:"+path.toString());
}
return this;
}
}
package cn.ibizlab.codegen.lite;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import cn.ibizlab.codegen.utils.DataObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
public class FieldModel {
private String columnName;
private String codeName;
private String unionName;
private String showName;
private String comment;
private MetaFieldModel field;
private RelationshipModel reference;
@JsonIgnore
@JSONField(serialize = false)
public String getColumnExp()
{
if(field.getPhysicalField()!=null && 1==field.getPhysicalField())
{
return columnName+" as \""+columnName.toUpperCase()+"\"";
}
else if(!StringUtils.isEmpty(field.getExpression()))
{
return field.getExpression()+" as \""+columnName.toUpperCase()+"\"";
}
return "";
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isPhysicalField()
{
return this.getField().getPhysicalField()!=null && 1==this.getField().getPhysicalField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isKeyField()
{
return this.getField().getKeyField()!=null && 1==this.getField().getKeyField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLogicValidField()
{
return "LOGICVALID".equals(this.getField().getPredefined());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLastModifyField()
{
return "UPDATEDATE".equals(this.getField().getPredefined());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isCreateTimeField()
{
return "CREATEDATE".equals(this.getField().getPredefined());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isUnionKeyField()
{
return !StringUtils.isEmpty(this.getField().getUnionKey());
}
public String getPropType()
{
String dataType=this.getField().getDataType().toUpperCase();
if( dataType.indexOf("TEXT")>=0||dataType.indexOf("CHAR")>=0||dataType.indexOf("LOB")>=0)
return "string";
else if(dataType.indexOf("TIME")>=0)
return "date-time";
else if(dataType.indexOf("DATE")>=0)
return "date";
else if(dataType.indexOf("NUM")>=0||dataType.indexOf("FLOAT")>=0||dataType.indexOf("DOUBLE")>=0||dataType.indexOf("DECIMAL")>=0)
return "number";
else if(dataType.indexOf("INT")==0)
return "integer";
return "string";
}
public String getColumnName(String dsType)
{
return DataObject.getStringValue(field.get("column-"+dsType.toLowerCase()),getColumnName());
}
@JsonIgnore
@JSONField(serialize = false)
private Object node;
}
package cn.ibizlab.codegen.lite;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import cn.ibizlab.codegen.utils.DataObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 实体[实体]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
public class MetaEntityModel{
/**
* 标识
*/
@JSONField(name = "entity_id")
@JsonProperty("entity_id")
private String entityId;
/**
* 实体名
*/
@JSONField(name = "entity_name")
@JsonProperty("entity_name")
private String entityName;
/**
* 逻辑名称
*/
@JSONField(name = "logic_name")
@JsonProperty("logic_name")
private String logicName;
/**
* 代码名称
*/
@JSONField(name = "code_name")
@JsonProperty("code_name")
private String codeName;
/**
* 表名称
*/
@JSONField(name = "table_name")
@JsonProperty("table_name")
private String tableName;
/**
* 系统标识
*/
@JSONField(name = "system_id")
@JsonProperty("system_id")
private String systemId;
/**
* 系统
*/
@JSONField(name = "system_name")
@JsonProperty("system_name")
private String systemName;
/**
* 数据源标识
*/
@JSONField(name = "ds_id")
@JsonProperty("ds_id")
private String dsId;
/**
* 数据源
*/
@JSONField(name = "ds_name")
@JsonProperty("ds_name")
private String dsName;
/**
* 模块标识
*/
@JSONField(name = "module_id")
@JsonProperty("module_id")
private String moduleId;
/**
* 模块
*/
@JSONField(name = "module_name")
@JsonProperty("module_name")
private String moduleName;
/**
* 扩展参数
*/
@JSONField(name = "ext_params")
@JsonProperty("ext_params")
private String extParams;
/**
* 排序
*/
@JSONField(name = "show_order")
@JsonProperty("show_order")
private Integer showOrder;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "createdate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
private Timestamp createdate;
/**
* 最后修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "updatedate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
private Timestamp updatedate;
@JSONField(serialize = false)
@JsonIgnore
private Map<String, Object> extensionparams;
public Object get(String key)
{
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
return extensionparams.get(key);
}
public MetaEntityModel set(String key, Object value)
{
if(value==null)
return this;
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String, Object> entry:extensionparams.entrySet()) {
if(!entry.getKey().equalsIgnoreCase("param"))
settingList.add(new Setting().setProperty(entry.getKey()).setValue(DataObject.getStringValue(entry.getValue(), "")));
}
return setExtParams(JSON.toJSONString(settingList));
}
}
package cn.ibizlab.codegen.lite;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import cn.ibizlab.codegen.utils.DataObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 实体[属性]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@ApiModel("属性")
public class MetaFieldModel {
/**
* 属性标识
*/
@JSONField(name = "field_id")
@JsonProperty("field_id")
@ApiModelProperty("属性标识")
private String fieldId;
/**
* 属性名称
*/
@JSONField(name = "field_name")
@JsonProperty("field_name")
@ApiModelProperty("属性名称")
private String fieldName;
/**
* 代码名称
*/
@JSONField(name = "code_name")
@JsonProperty("code_name")
@ApiModelProperty("代码名称")
private String codeName;
/**
* 实体标识
*/
@JSONField(name = "entity_id")
@JsonProperty("entity_id")
@ApiModelProperty("实体标识")
private String entityId;
/**
* 实体名称
*/
@JSONField(name = "entity_name")
@JsonProperty("entity_name")
@ApiModelProperty("实体名称")
private String entityName;
/**
* 实体代码名称
*/
@JSONField(name = "entity_code_name")
@JsonProperty("entity_code_name")
@ApiModelProperty("实体代码名称")
private String entityCodeName;
/**
* 系统
*/
@JSONField(name = "system_id")
@JsonProperty("system_id")
@ApiModelProperty("系统")
private String systemId;
/**
* 属性逻辑名
*/
@JSONField(name = "field_logic_name")
@JsonProperty("field_logic_name")
@ApiModelProperty("属性逻辑名")
private String fieldLogicName;
/**
* 属性全路径名称
*/
@JSONField(name = "field_uni_name")
@JsonProperty("field_uni_name")
@ApiModelProperty("属性全路径名称")
private String fieldUniName;
/**
* 显示名称
*/
@JSONField(name = "field_show_name")
@JsonProperty("field_show_name")
@ApiModelProperty("显示名称")
private String fieldShowName;
/**
* 引用属性标识
*/
@JSONField(name = "ref_field_id")
@JsonProperty("ref_field_id")
@ApiModelProperty("引用属性标识")
private String refFieldId;
/**
* 引用属性名称
*/
@JSONField(name = "ref_field_name")
@JsonProperty("ref_field_name")
@ApiModelProperty("引用属性名称")
private String refFieldName;
/**
* 引用属性代码名称
*/
@JSONField(name = "ref_field_code_name")
@JsonProperty("ref_field_code_name")
@ApiModelProperty("引用属性代码名称")
private String refFieldCodeName;
/**
* 引用关系标识
*/
@JSONField(name = "relation_id")
@JsonProperty("relation_id")
@ApiModelProperty("引用关系标识")
private String relationId;
/**
* 引用关系
*/
@JSONField(name = "relation_name")
@JsonProperty("relation_name")
@ApiModelProperty("引用关系")
private String relationName;
/**
* 关系代码
*/
@JSONField(name = "relation_code_name")
@JsonProperty("relation_code_name")
@ApiModelProperty("关系代码")
private String relationCodeName;
/**
* 引用实体
*/
@JSONField(name = "ref_entity_name")
@JsonProperty("ref_entity_name")
@ApiModelProperty("引用实体")
private String refEntityName;
/**
* 主键
*/
@JSONField(name = "key_field")
@JsonProperty("key_field")
@ApiModelProperty("主键")
private Integer keyField;
/**
* 主信息
*/
@JSONField(name = "major_field")
@JsonProperty("major_field")
@ApiModelProperty("主信息")
private Integer majorField;
/**
* 联合主键
*/
@JSONField(name = "union_key")
@JsonProperty("union_key")
@ApiModelProperty("联合主键")
private String unionKey;
/**
* 属性类型
*/
@JSONField(name = "field_type")
@JsonProperty("field_type")
@ApiModelProperty("属性类型")
private String fieldType;
/**
* 预定义类型
*/
@JSONField(name = "predefined")
@JsonProperty("predefined")
@ApiModelProperty("预定义类型")
private String predefined;
/**
* 数据字典
*/
@JSONField(name = "dict")
@JsonProperty("dict")
@ApiModelProperty("数据字典")
private String dict;
/**
* 允许为空
*/
@JSONField(name = "nullable")
@JsonProperty("nullable")
@ApiModelProperty("允许为空")
private Integer nullable;
/**
* 物理属性
*/
@JSONField(name = "physical_field")
@JsonProperty("physical_field")
@ApiModelProperty("物理属性")
private Integer physicalField;
/**
* 数据类型
*/
@JSONField(name = "data_type")
@JsonProperty("data_type")
@ApiModelProperty("数据类型")
private String dataType;
/**
* 长度
*/
@JSONField(name = "data_length")
@JsonProperty("data_length")
@ApiModelProperty("长度")
private Integer dataLength;
/**
* 精度
*/
@JSONField(name = "data_preci")
@JsonProperty("data_preci")
@ApiModelProperty("精度")
private Integer dataPreci;
/**
* 逻辑表达式
*/
@JSONField(name = "expression")
@JsonProperty("expression")
@ApiModelProperty("逻辑表达式")
private String expression;
/**
* 扩展属性
*/
@JSONField(name = "extension_field")
@JsonProperty("extension_field")
@ApiModelProperty("扩展属性")
private Integer extensionField;
/**
* 审计
*/
@JSONField(name = "is_enable_audit")
@JsonProperty("is_enable_audit")
@ApiModelProperty("审计")
private Integer isEnableAudit;
/**
* 排序
*/
@JSONField(name = "show_order")
@JsonProperty("show_order")
@ApiModelProperty("排序")
private Integer showOrder;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "createdate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
@ApiModelProperty("创建时间")
private Timestamp createdate;
/**
* 最后修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "updatedate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
@ApiModelProperty("最后修改时间")
private Timestamp updatedate;
/**
* 扩展参数
*/
@JSONField(name = "ext_params")
@JsonProperty("ext_params")
private String extParams;
@JSONField(serialize = false)
@JsonIgnore
private Map<String, Object> extensionparams;
public Object get(String key)
{
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
return extensionparams.get(key);
}
public MetaFieldModel set(String key, Object value)
{
if(value==null)
return this;
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String, Object> entry:extensionparams.entrySet()) {
if(!entry.getKey().equalsIgnoreCase("param"))
settingList.add(new Setting().setProperty(entry.getKey()).setValue(DataObject.getStringValue(entry.getValue(), "")));
}
return setExtParams(JSON.toJSONString(settingList));
}
}
package cn.ibizlab.codegen.lite;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
/**
* 实体[实体关系]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@ApiModel("实体关系")
public class MetaRelationshipModel implements Serializable {
/**
* 关系标识
*/
@JSONField(name = "id")
@JsonProperty("id")
@ApiModelProperty("关系标识")
private String id;
/**
* 关系名称
*/
@JSONField(name = "name")
@JsonProperty("name")
@ApiModelProperty("关系名称")
private String name;
/**
* 类型
*/
@JSONField(name = "relation_type")
@JsonProperty("relation_type")
@ApiModelProperty("类型")
private String relationType;
/**
* 代码名称
*/
@JSONField(name = "code_name")
@JsonProperty("code_name")
@ApiModelProperty("代码名称")
private String codeName;
/**
* 实体标识
*/
@JSONField(name = "entity_id")
@JsonProperty("entity_id")
@ApiModelProperty("实体标识")
private String entityId;
/**
* 实体名称
*/
@JSONField(name = "entity_name")
@JsonProperty("entity_name")
@ApiModelProperty("实体名称")
private String entityName;
/**
* 实体代码名称
*/
@JSONField(name = "entity_code_name")
@JsonProperty("entity_code_name")
@ApiModelProperty("实体代码名称")
private String entityCodeName;
/**
* 引用实体标识
*/
@JSONField(name = "ref_entity_id")
@JsonProperty("ref_entity_id")
@ApiModelProperty("引用实体标识")
private String refEntityId;
/**
* 引用实体名称
*/
@JSONField(name = "ref_entity_name")
@JsonProperty("ref_entity_name")
@ApiModelProperty("引用实体名称")
private String refEntityName;
/**
* 引用实体代码名称
*/
@JSONField(name = "ref_entity_code_name")
@JsonProperty("ref_entity_code_name")
@ApiModelProperty("引用实体代码名称")
private String refEntityCodeName;
/**
* 嵌套代码名称
*/
@JSONField(name = "nested_name")
@JsonProperty("nested_name")
@ApiModelProperty("嵌套代码名称")
private String nestedName;
/**
* 系统
*/
@JSONField(name = "system_id")
@JsonProperty("system_id")
@ApiModelProperty("系统")
private String systemId;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "createdate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
@ApiModelProperty("创建时间")
private Timestamp createdate;
/**
* 最后修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "updatedate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
@ApiModelProperty("最后修改时间")
private Timestamp updatedate;
/**
* lookup
*/
@JSONField(name = "lookups")
@JsonProperty("lookups")
private List<MetaLookupModel> lookup;
public MetaRelationshipModel addLookup(MetaLookupModel obj)
{
if(lookup==null)
lookup=new ArrayList<>();
lookup.add(obj);
return this;
}
}
package cn.ibizlab.codegen.lite;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import cn.ibizlab.codegen.utils.DataObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.io.StringReader;
import java.util.*;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class Setting {
private String property;
private String value;
public static String getValue(String configString, String propertyName)
{
return DataObject.getStringValue(getMap(configString).get(propertyName),"");
}
public static Map getMap(String configString)
{
Map map=new HashMap();
map.put("param",configString);
if(!(StringUtils.isEmpty(configString)))
{
try
{
Object obj= JSON.parse(configString);
if(obj==null)
return map;
else if (obj instanceof JSONArray)
{
List<Setting> settings= JSONArray.parseArray(configString,Setting.class);
for(Setting setting:settings)
map.put(setting.getProperty(),setting.getValue());
}
else if (obj instanceof JSONObject)
{
JSONObject jo = (JSONObject)obj;
jo.keySet().forEach(key->{
map.put(key,jo.get(key));
});
}
}
catch (Exception ex)
{
if(configString.indexOf("=")>0)
{
Properties proper = new Properties();
try {
proper.load(new StringReader(configString)); //把字符串转为reader
} catch (IOException e) {
}
Enumeration enum1 = proper.propertyNames();
while (enum1.hasMoreElements()) {
String strKey = (String) enum1.nextElement();
String strValue = proper.getProperty(strKey);
map.put(strKey, strValue);
}
}
}
}
return map;
}
}
package cn.ibizlab.codegen.lite;
package cn.ibizlab.codegen.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......@@ -19,7 +19,7 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@ApiModel("数据集")
public class MetaDataSetModel {
public class DataSetModel {
/**
* 标识
......
package cn.ibizlab.codegen.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.defield.IPSDEField;
import org.springframework.util.StringUtils;
import java.util.LinkedHashSet;
import java.util.Set;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
public class FieldModel {
public String getCodeName() {
return getField().getCodeName();
}
public String getFieldName() {
return getField().getName();
}
public String getColumnName(){
return getField().getName();
}
public String getLogicName() {
return getField().getLogicName();
}
public DataType getType()
{
return DataType.findTypeName(this.getField().getStdDataType());
}
private String expression;
private IPSDEField field;
private RelationshipModel reference;
private String refFieldName;
private String refFieldCodeName;
@JsonIgnore
@JSONField(serialize = false)
public boolean isPhysicalField()
{
return this.getField().isPhisicalDEField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isKeyField()
{
return this.getField().isKeyDEField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLogicValidField()
{
return "LOGICVALID".equals(this.getField().getPredefinedType());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLastModifyField()
{
return "UPDATEDATE".equals(this.getField().getPredefinedType());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isCreateTimeField()
{
return "CREATEDATE".equals(this.getField().getPredefinedType());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isUnionKeyField()
{
return !StringUtils.isEmpty(this.getField().getUnionKeyValue());
}
public String getDefaultValue()
{
if((!StringUtils.isEmpty(getField().getDefaultValueType()))||(!StringUtils.isEmpty(getField().getDefaultValue())))
{
String defaultValue="";
if(StringUtils.isEmpty(getField().getDefaultValueType())||"NONE".equalsIgnoreCase(getField().getDefaultValueType()))
{
defaultValue=getField().getDefaultValue();
}
else if(!StringUtils.isEmpty(getField().getDefaultValue()))
{
defaultValue= String.format("${%1$s.%2$s}",getField().getDefaultValueType(),getField().getDefaultValue());
}
else
{
defaultValue= String.format("${%1$s}",getField().getDefaultValueType());
}
return defaultValue;
}
return null;
}
public Set<String> getSearchMode()
{
Set<String> modes=new LinkedHashSet<>();
if(getField().getAllPSDEFSearchModes()!=null)
{
getField().getAllPSDEFSearchModes().forEach(item->modes.add(item.getValueOP().toLowerCase()));
}
if(getField().isEnableQuickSearch())
modes.add("query");
return modes;
}
private DataObj extParams=new DataObj();
public FieldModel set(String key,Object val)
{
extParams.set(key,val);
return this;
}
public String getStringValue(String key,String defaultVal)
{
return extParams.getStringValue(key,defaultVal);
}
public String getColumnName(String dsType)
{
return this.getStringValue("column-"+dsType.toLowerCase(),getColumnName());
}
public static enum DataType {
UNKNOWN(0,"UNKNOWN","string","String"),
BIGINT(1,"BIGINT","number","Long"),
BINARY(2,"BINARY","string","String"),
BIT(3,"BIT","boolean","Boolean"),
CHAR(4,"CHAR","string","String"),
DATETIME(5,"DATETIME","string", "Timestamp"),
DECIMAL(6,"DECIMAL","number", "BigDecimal"),
FLOAT(7,"FLOAT","number", "BigDecimal"),
IMAGE(8,"IMAGE","string","String"),
INT(9,"INT","number","Integer"),
MONEY(10,"MONEY","number", "BigDecimal"),
NCHAR(11,"NCHAR","string","String"),
NTEXT(12,"NTEXT","string","String"),
NVARCHAR(13,"NVARCHAR","string","String"),
NUMERIC(14,"NUMERIC","number", "BigDecimal"),
REAL(15,"REAL","number","Float"),
SMALLDATETIME(16,"SMALLDATETIME","string", "Timestamp"),
SMALLINT(17,"SMALLINT","number","Integer"),
SMALLMONEY(18,"SMALLMONEY","number", "BigDecimal"),
SQL_VARIANT(19,"SQL_VARIANT","string","String"),
SYSNAME(20,"SYSNAME","string","String"),
TEXT(21,"TEXT","string","String"),
TIMESTAMP(22,"TIMESTAMP","string","Timestamp"),
TINYINT(23,"TINYINT","number","Integer"),
VARBINARY(24,"VARBINARY","string","String"),
VARCHAR(25,"VARCHAR","string","String"),
UNIQUEIDENTIFIER(26,"UNIQUEIDENTIFIER","string","String"),
DATE(27,"DATE","string", "Timestamp"),
TIME(28,"TIME","string", "Timestamp");
public final int code;
public final String name;
public final String prop;
public final String java;
private DataType(int code, String name, String prop, String java) {
this.code = code;
this.name = name;
this.prop = prop;
this.java = java;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
public String getProp() {
return prop;
}
public String getJava() {
return java;
}
public static DataType findTypeName(Integer type) {
for (DataType userTypeEnum : DataType.values()) {
if (userTypeEnum.getCode()==type) {
return userTypeEnum;
}
}
return VARCHAR;
}
}
}
package cn.ibizlab.codegen.lite;
package cn.ibizlab.codegen.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
......@@ -20,7 +20,7 @@ import java.io.Serializable;
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("lookup")
public class MetaLookupModel implements Serializable {
public class LookupModel implements Serializable {
/**
* 标识
......
package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.lite.DynamicModelStorage;
import cn.ibizlab.codegen.lite.EntityModel;
import cn.ibizlab.codegen.CodegenConfig;
import cn.ibizlab.codegen.CodegenConstants;
......@@ -60,25 +58,7 @@ public class ModelStorage {
}
public PojoSchema getEntitySchema(String entity)
{
EntityModel entityModel= null;
try {
entityModel = dynamicService.getDynamicEntity(entity);
} catch (Exception exception) {
exception.printStackTrace();
}
Assert.notNull(entityModel,"loadDOModel未找到实体"+"."+entity);
PojoSchema schema = TransUtils.EntityModelModel2Schema(entityModel);
Assert.notNull(schema,"loadDOModel未找到实体"+"."+entity);
for (String dsType : entityModel.getDsTypes()) {
POSchema poSchema = TransUtils.EntityModelModel2PO(entityModel, dsType);
if (poSchema != null) {
schema.addPOSchema(dsType, poSchema);
}
}
return schema;
}
private Map<TemplateFileType,CliData> templateData=new HashMap<>();
......@@ -122,9 +102,9 @@ public class ModelStorage {
else if(type.equals(TemplateFileType.entity))
{
dynamicService.getPSSystem().getAllPSDataEntities().forEach(item->{
PojoSchema pojoSchema=this.getEntitySchema(item.getName());
CliOption opt=newCliOption(TemplateFileType.entity).setCliSubType(pojoSchema.getStorageMode()).setModule(pojoSchema.getModule())
.baseData(pojoSchema,item.getCodeName());
EntityModel schema=dynamicService.getEntitySchema(item.getId());
CliOption opt=newCliOption(TemplateFileType.entity).setCliSubType(schema.getStorageMode()).setModule(schema.getModule())
.baseData(schema,item.getCodeName());
rt.addOption(opt);
});
}
......
......@@ -626,16 +626,7 @@ public class PojoSchema {
}
}
if(("default".equals(name)||this.getDefaultDataSoruce().equalsIgnoreCase(name)))
{
POSchema defaultPOSchema= TransUtils.PojoSchema2PO(this);
if(defaultPOSchema!=null) {
poSchemas.put("default", defaultPOSchema);
if(!StringUtils.isEmpty(this.getDefaultDataSoruce()))
poSchemas.put(this.getDefaultDataSoruce().toLowerCase(),defaultPOSchema);
return defaultPOSchema;
}
}
return null;
}
......
package cn.ibizlab.codegen.lite;
package cn.ibizlab.codegen.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.der.IPSDERBase;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
......@@ -15,6 +17,8 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(value = "handler")
public class RelationshipModel {
private String name;
private String codeName;
private String entityName;
......@@ -23,18 +27,34 @@ public class RelationshipModel {
private String entityLogicName;
private String systemId;
private String dataSourceName;
private String tableName;
private String entityId;
private MetaRelationshipModel relation;
private String relationType;
private IPSDERBase relation;
private List<FieldModel> fields;
public RelationshipModel addField(FieldModel obj)
{
if(fields==null)
fields=new ArrayList<>();
fields.add(obj);
return this;
}
private List<LookupModel> lookup;
public RelationshipModel addLookup(LookupModel obj)
{
if(lookup==null)
lookup=new ArrayList<>();
lookup.add(obj);
return this;
}
@JsonIgnore
@JSONField(serialize = false)
private Object node;
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册