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

提交

上级 b457b716
......@@ -100,7 +100,7 @@
<dependency>
<groupId>net.ibizsys.model</groupId>
<artifactId>ibizlab-model</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
</dependencies>
......
......@@ -280,10 +280,14 @@ public class DOModel extends EntityBase implements Serializable {
return getPOSchema("default");
}
public DOModel addPOSchema(String name,POSchema poSchema)
{
if(poSchema!=null)
{
if(poSchemas==null)
poSchemas=new LinkedHashMap<>();
poSchemas.put(name,poSchema);
poSchemas.put(name,poSchema.build());
}
return this;
}
public POSchema getPOSchema(String name)
......
......@@ -4,6 +4,7 @@ import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSON;
import net.ibizsys.model.IPSSystem;
import net.ibizsys.model.PSModelServiceImpl;
import net.ibizsys.model.database.IPSDEFDTColumn;
import net.ibizsys.model.database.IPSSysDBTable;
import net.ibizsys.model.dataentity.IPSDataEntity;
import net.ibizsys.model.dataentity.defield.IPSDEField;
......@@ -58,7 +59,7 @@ public class DynamicModelService {
IPSSystem iPSSystem = null;
String strPSModelFolderPath=null;
if(Files.exists(Paths.get(getModelPath(),system,"model","PSSYSTEM.json"))) {
strPSModelFolderPath=Paths.get(getModelPath(),system,"model","PSSYSTEM.json").toString();
strPSModelFolderPath=Paths.get(getModelPath(),system,"model").toString();
}
else
{
......@@ -183,10 +184,24 @@ public class DynamicModelService {
}
entityModel.setEntity(metaEntityModel);
List<String> dsTypes=new ArrayList<>();
if(dataEntity.getAllPSDEDBConfigs()!=null)
{
dataEntity.getAllPSDEDBConfigs().forEach(item->{
dsTypes.add(item.getDBType().toLowerCase());
if(!entityModel.getTableName().equalsIgnoreCase(item.getTableName()))
entityModel.getEntity().set("table-"+item.getDBType().toLowerCase(),item.getTableName());
});
}
if(dsTypes.size()>0)
entityModel.getEntity().set("ds_types",String.join(",",dsTypes));
Map<String,FieldModel> fieldMaps=new LinkedHashMap<>();
for(IPSDEField defield:dataEntity.getAllPSDEFields())
{
FieldModel fieldModel=new FieldModel();
MetaFieldModel metaFieldModel=new MetaFieldModel();
metaFieldModel.setFieldId(defield.getId()).setFieldName(defield.getName()).setCodeName(defield.getCodeName()).setFieldLogicName(defield.getLogicName())
......@@ -203,7 +218,7 @@ public class DynamicModelService {
if(!metaFieldModel.getFieldName().equalsIgnoreCase(col.getColumnName()))
metaFieldModel.set("column-"+col.getDBType().toLowerCase(),col.getColumnName());
if(StringUtils.isEmpty(metaFieldModel)&&defield.isFormulaDEField()&&(!StringUtils.isEmpty(col.getQueryCodeExp())))
metaFieldModel.setExpression(col.getQueryCodeExp().replace("`",""));
metaFieldModel.setExpression(col.getQueryCodeExp().replace("`","").replace("[","").replace("]",""));
});
}
......@@ -233,7 +248,7 @@ public class DynamicModelService {
MetaRelationshipModel metaRel=new MetaRelationshipModel();
metaRel.setId(der.getId()).setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getCodeName()).setRefEntityId(der.getMajorPSDataEntity().getId())
.setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setName(dataEntity.getName()).setNestedName(der.getMinorCodeName())
.setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setEntityName(dataEntity.getName()).setNestedName(der.getMinorCodeName())
.setSystemId(iPSSystem.getCodeName());
if(der instanceof IPSDER1N)
......@@ -263,7 +278,7 @@ public class DynamicModelService {
MetaRelationshipModel metaRel=new MetaRelationshipModel();
metaRel.setId(der.getId()).setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getCodeName()).setRefEntityId(der.getMajorPSDataEntity().getId())
.setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setName(dataEntity.getName()).setNestedName(der.getMinorCodeName())
.setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setEntityName(dataEntity.getName()).setNestedName(der.getMinorCodeName())
.setSystemId(iPSSystem.getCodeName());
if(der instanceof IPSDER1N)
......@@ -287,7 +302,7 @@ public class DynamicModelService {
if(dataQuery.getAllPSDEDataQueryCodes()!=null)
{
dataQuery.getAllPSDEDataQueryCodes().forEach(dq->{
MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId("dq-"+dataQuery.getCodeName()+"-"+dq.getDBType().toLowerCase())
MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId(entityModel.getEntityName().toLowerCase()+"-dq-"+dataQuery.getCodeName()+"-"+dq.getDBType().toLowerCase())
.setDatasetName(dataQuery.getLogicName()).setCodeName(dataQuery.getCodeName())
.setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(dq.getQueryCode());
entityModel.addDataSet(dsModel);
......@@ -306,8 +321,12 @@ public class DynamicModelService {
try {
if(dataSet.getPSDEDataQueries()!=null)
{
Map<String,String> map =new HashMap<>();
dataSet.getPSDEDataQueries().forEach(dataQuery->{
......@@ -324,7 +343,7 @@ public class DynamicModelService {
code = map.get(dq.getDBType());
code = code+"\r\n union all \r\n";
}
code = code+dq.getQueryCode();
code = code+"<include refid=\""+entityModel.getEntityName().toLowerCase()+"_dq_"+dataQuery.getCodeName()+"_"+dq.getDBType().toLowerCase()+"\"/>";
map.put(dq.getDBType(),code);
});
}
......@@ -336,9 +355,27 @@ public class DynamicModelService {
for(Map.Entry<String,String> entry:map.entrySet())
{
MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId("ds-"+dataSet.getCodeName()+"-"+entry.getKey().toLowerCase())
String sql="select t1.* from (\r\n".concat(entry.getValue()).concat("\r\n) t1");
if(dataSet.getMajorSortPSDEField()!=null)
{
IPSDEFDTColumn column = dataSet.getMajorSortPSDEField().getPSDEFDTColumn(entry.getKey(),false);
sql=sql.concat(" order by ").concat(column==null?dataSet.getMajorSortPSDEField().getName():column.getColumnName());
if(!StringUtils.isEmpty(dataSet.getMajorSortDir()))
sql=sql.concat(" ").concat(dataSet.getMajorSortDir());
if(dataSet.getMinorSortPSDEField()!=null)
{
IPSDEFDTColumn subCol = dataSet.getMinorSortPSDEField().getPSDEFDTColumn(entry.getKey(),false);
sql=sql.concat(",").concat(subCol==null?dataSet.getMinorSortPSDEField().getName():subCol.getColumnName());
if(!StringUtils.isEmpty(dataSet.getMinorSortDir()))
sql=sql.concat(" ").concat(dataSet.getMinorSortDir());
}
}
MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId(entityModel.getEntityName().toLowerCase()+"-ds-"+dataSet.getCodeName()+"-"+entry.getKey().toLowerCase())
.setDatasetName(dataSet.getLogicName()).setCodeName(dataSet.getCodeName())
.setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(entry.getValue());
.setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(sql);
entityModel.addDataSet(dsModel);
}
......@@ -348,6 +385,8 @@ public class DynamicModelService {
}
});
}
......
......@@ -277,6 +277,35 @@ public class EntityModel {
return null;
}
@JsonIgnore
@JSONField(serialize = false)
public String getDefaultQueryScript()
{
if(this.getDataSets()!=null)
{
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if("view".equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().startsWith("dq-view-")||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-dq-view-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if("default".equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().startsWith("dq-default-")||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-dq-default-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
}
return "";
}
public String getSqlSegment(String dataSet)
{
......@@ -298,6 +327,35 @@ public class EntityModel {
{
return "select count(1) from "+this.getTableName()+" ";
}
else if(this.getDataSets()!=null)
{
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if(dataSet.equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().indexOf("ds-"+dataSet.toLowerCase()+"-")>=0||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-ds-"+dataSet.toLowerCase()+"-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if(dataSet.equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().indexOf("dq-"+dataSet.toLowerCase()+"-")>=0||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-dq-"+dataSet.toLowerCase()+"-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
}
if(dataSet.equalsIgnoreCase("VIEW")||dataSet.equalsIgnoreCase("DEFAULT"))
{
return "";
}
else
{
String columnSet="";
......@@ -417,7 +475,23 @@ public class EntityModel {
public String getExtParams(String key)
{
return Setting.getValue(this.getEntity().getExtParams(),key);
return DataObject.getStringValue(entity.get(key),"");
}
public String getTableName(String dsType)
{
return DataObject.getStringValue(entity.get("table-"+dsType.toLowerCase()),getTableName());
}
@JsonIgnore
@JSONField(serialize = false)
public List<String> getDsTypes()
{
List<String> dsTypes=new ArrayList<>();
String strDsTypes=DataObject.getStringValue(entity.get("ds_types"),"");
for(String dsType:strDsTypes.split(","))
dsTypes.add(dsType);
return dsTypes;
}
......
package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......@@ -103,5 +104,9 @@ public class FieldModel {
return "string";
}
public String getColumnName(String dsType)
{
return DataObject.getStringValue(field.get("column-"+dsType.toLowerCase()),getColumnName());
}
}
......@@ -142,8 +142,10 @@ public class MetaEntityModel{
extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String,Object> entry:extensionparams.entrySet())
settingList.add(new Setting().setProperty(key).setValue(DataObject.getStringValue(value,"")));
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));
}
......
......@@ -293,8 +293,10 @@ public class MetaFieldModel {
extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String,Object> entry:extensionparams.entrySet())
settingList.add(new Setting().setProperty(key).setValue(DataObject.getStringValue(value,"")));
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.core.data.model;
import cn.ibizlab.core.data.dto.BaseData;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......@@ -12,6 +15,10 @@ import lombok.experimental.Accessors;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.springframework.util.StringUtils;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.*;
@Getter
......@@ -22,15 +29,21 @@ import java.util.*;
@JsonIgnoreProperties(ignoreUnknown = true)
public class POSchema {
@JSONField(ordinal = 1)
private String name;
@JSONField(ordinal = 2)
private String remarks;
@JSONField(ordinal = 3)
private String dsType;
@JSONField(ordinal = 4)
private String defaultDataSource;
@JSONField(ordinal = 5)
private String logicVal;
@JSONField(ordinal = 6)
private String logicDelVal;
public String getLogicVal() {
......@@ -45,8 +58,10 @@ public class POSchema {
return logicDelVal;
}
@JSONField(ordinal = 7)
private List<Column> columns;
@JSONField(ordinal = 8)
private List<Column> transients;
public POSchema setColumns(List<Column> columns)
......@@ -81,6 +96,7 @@ public class POSchema {
return this;
}
@JSONField(ordinal = 9)
private List<ForeignKeyConstraint> foreignKeyConstraints;
public POSchema addForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint)
......@@ -120,6 +136,7 @@ public class POSchema {
return columnMaps;
}
@JSONField(ordinal = 10)
public boolean needTrans = false;
public void refreshColumnMaps()
......@@ -174,7 +191,7 @@ public class POSchema {
if(column.isLastModify())
this.setLastModifyColumn(column);
}
if((!StringUtils.isEmpty(column.getAlias()))&&column.getAlias().equalsIgnoreCase(column.getName()))
if((!StringUtils.isEmpty(column.getAlias()))&&(!column.getAlias().equalsIgnoreCase(column.getName())))
{
needTrans=true;
columnMaps.put(column.getAlias().toLowerCase(), column);
......@@ -300,6 +317,12 @@ public class POSchema {
private String alias;
private String predefined;
public Column setAlias(String alias)
{
if((!StringUtils.isEmpty(name))&&(!name.equalsIgnoreCase(alias)))
this.alias=alias;
return this;
}
@JsonIgnore
@JSONField(serialize = false)
......@@ -447,21 +470,38 @@ public class POSchema {
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Script{
public static class Segment{
private String name;
private String vendorProvider;
private String declare;
private String body;
private Map params;
public Segment setVendorProvider(String vendorProvider)
{
if(!StringUtils.isEmpty(vendorProvider))
this.vendorProvider=provider.get(vendorProvider.toLowerCase());
return this;
}
}
public List<Script> scripts;
@JSONField(ordinal = 11)
public List<Segment> segments;
public POSchema addSegment(Segment segment)
{
if(segments==null)
segments=new ArrayList<>();
segments.add(segment);
return this;
}
private static Map<String, String> provider = new HashMap<String, String>(){{
put("oracle", "oracle");
put("mysql", "mysql");
put("mysql5", "mysql");
put("postgresql", "postgresql");
put("mppdb", "postgresql");
put("dm", "oracle");
......@@ -472,39 +512,60 @@ public class POSchema {
public Script getScript(String name,String type)
public Segment getSegment(String name,String type)
{
if(scripts!=null)
if(segments!=null)
{
String vendorProvider="mysql";
if((!StringUtils.isEmpty(type))&&provider.containsKey(type.toLowerCase()))
vendorProvider=provider.get(type.toLowerCase());
for(Script script:scripts)
String vendorProvider=StringUtils.isEmpty(type)?"":provider.get(type.toLowerCase());
for(Segment script:segments)
{
if(name.equalsIgnoreCase(script.getName())&&((script.getVendorProvider().indexOf(vendorProvider)>=0)||StringUtils.isEmpty(script.getVendorProvider())))
if(script.getName().toLowerCase().indexOf(name.toLowerCase())>=0&&(StringUtils.isEmpty(vendorProvider)||script.getVendorProvider().indexOf(vendorProvider)>=0||StringUtils.isEmpty(script.getVendorProvider())))
return script;
}
}
else
{
scripts=new ArrayList<>();
segments=new ArrayList<>();
}
return getDefaultQueryScript();
return null;
}
@JsonIgnore
@JSONField(serialize = false)
public Script defaultQueryScript;
@JSONField(ordinal = 12)
public Segment defaultQueryScript;
@JsonIgnore
@JSONField(serialize = false)
public Script getDefaultQueryScript()
public POSchema setDefaultQueryScript(String sql)
{
defaultQueryScript=new Segment().setName("default_query_script").setVendorProvider("").setBody(sql);
return this;
}
public Segment getDefaultQueryScript()
{
if(defaultQueryScript==null)
{
defaultQueryScript=new Script();
defaultQueryScript.setName("default");
defaultQueryScript.setVendorProvider("mysql,oracle,postgresql");
Segment segment=this.getSegment("dq-view-",this.getDsType());
if(segment==null)
segment=this.getSegment("dq-default-",this.getDsType());
if(segment!=null)
{
setDefaultQueryScript(segment.getBody());
return defaultQueryScript;
}
else if(!StringUtils.isEmpty(this.getDsType()))
{
segment=this.getSegment("dq-view-","");
if(segment==null)
segment=this.getSegment("dq-default-","");
if(segment!=null)
{
setDefaultQueryScript(segment.getBody().replace("`","").replace("[","").replace("]",""));
return defaultQueryScript;
}
}
defaultQueryScript=new Segment();
defaultQueryScript.setName("default_query_script");
defaultQueryScript.setVendorProvider("");
String sql="select ";
String cols="";
......@@ -514,18 +575,18 @@ public class POSchema {
{
if(!StringUtils.isEmpty(cols))
cols+=",";
cols+=("t."+key+" as "+baseColumnMap.get(key));
cols+=("t1."+key+" as "+baseColumnMap.get(key));
}
}
else
cols="*";
cols="t1.*";
sql += (cols+" from "+name+" t ");
sql += (cols+" from "+name+" t1 ");
if(isLogicValid())
{
sql += " where t."+this.getLogicValidCond();
sql += " where t1."+this.getLogicValidCond();
}
defaultQueryScript.setBody(sql);
......@@ -574,4 +635,36 @@ public class POSchema {
}
}
public POSchema writeTo(Path path)
{
return writeTo(this,path);
}
public static POSchema fromPath(Path path)
{
try {
if(!Files.exists(path))
throw new BadRequestAlertException("读取文件失败","POSchema",path.toString());
return JSON.parseObject(Files.readAllBytes(path),POSchema.class);
} catch (Exception e) {
throw new BadRequestAlertException("解析文件失败","POSchema",path.toString());
}
}
public static POSchema writeTo(POSchema poSchema,Path path)
{
try {
File dir=path.getParent().toFile();
if(!dir.exists())
dir.mkdirs();
Files.write(path, JSON.toJSONBytes(poSchema), StandardOpenOption.CREATE);
} catch (Exception e) {
throw new BadRequestAlertException("保存文件失败","POSchema",path.toString());
}
return poSchema;
}
}
package cn.ibizlab.core.data.model;
import cn.ibizlab.core.data.dto.DataObj;
import cn.ibizlab.util.helper.DataObject;
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 org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
......@@ -55,12 +58,28 @@ public class PojoOption extends DataObj
return this.getStringValue("ds_name",this.getSystem()+"-master");
}
public List<String> getDsTypes(){
List<String> dsTypes=new ArrayList<>();
String strDsTypes= this.getStringValue("ds_types");
for(String dsType:strDsTypes.split(","))
dsTypes.add(dsType);
return dsTypes;
}
public PojoOption setDsTypes(String dsTypes){
return this.set("ds_types",dsTypes);
}
public String getDefaultQueryScript()
{
return this.getStringValue("default_query_script");
}
public Boolean isLogicValid() {
return this.getBooleanValue("logicValid");
return this.getBooleanValue("logic_valid");
}
public PojoOption setLogicValid(Boolean logicValid) {
return this.set("logicValid",logicValid);
return this.set("logic_valid",logicValid);
}
public String getLogicVal()
......
......@@ -13,6 +13,7 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
......@@ -326,6 +327,10 @@ public class PojoSchema {
public static PojoSchema writeTo(PojoSchema pojoSchema,Path path)
{
try {
File dir=path.getParent().toFile();
if(!dir.exists())
dir.mkdirs();
Files.write(path, JSON.toJSONBytes(pojoSchema), StandardOpenOption.CREATE);
} catch (Exception e) {
throw new BadRequestAlertException("保存文件失败","PojoSchema",path.toString());
......
package cn.ibizlab.core.data.service.impl;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import java.nio.file.StandardOpenOption;
import java.util.*;
import cn.ibizlab.core.data.lite.EntityModel;
import cn.ibizlab.core.data.lite.LiteStorage;
import cn.ibizlab.core.data.model.POSchema;
import cn.ibizlab.core.data.model.PojoSchema;
import cn.ibizlab.core.data.model.TransUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
......@@ -71,18 +74,56 @@ public class DOModelServiceImpl implements IDOModelService {
String entity=args[2];
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo","domain",entity+".json");
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"domain",entity+".json");
if(!Files.exists(storePath))
{
EntityModel entityModel= LiteStorage.getEntityModel(system,entity);
if(entityModel!=null) {
schema=TransUtils.EntityModelModel2Schema(entityModel);
if(schema!=null)
{
for(String dsType:entityModel.getDsTypes())
{
POSchema poSchema=TransUtils.EntityModelModel2PO(entityModel,dsType);
if(poSchema!=null)
{
doModel.addPOSchema(dsType,poSchema);
}
}
if(doModel.getPoSchemas()!=null)
{
Path poPath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"repository",entity+".json");
try {
File dir=poPath.getParent().toFile();
if(!dir.exists())
dir.mkdirs();
Files.write(poPath, JSON.toJSONBytes(doModel.getPoSchemas()), StandardOpenOption.CREATE);
} catch (Exception e) {
throw new BadRequestAlertException("保存文件失败","POSchemas",poPath.toString());
}
}
schema.writeTo(storePath);
}
}
}
else {
schema = PojoSchema.fromPath(storePath);
Path poPath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"repository",entity+".json");
if(Files.exists(poPath))
{
try {
LinkedHashMap map=JSON.parseObject(Files.readAllBytes(poPath), LinkedHashMap.class);
map.keySet().forEach(dsType->{
doModel.addPOSchema(dsType.toString(),JSON.parseObject(JSON.toJSONString(map.get(dsType)),POSchema.class));
});
} catch (IOException e) {
}
}
}
else
schema=PojoSchema.fromPath(storePath);
if(schema!=null)
......
......@@ -68,12 +68,14 @@ public class DTOModelServiceImpl implements IDTOModelService {
String system=args[0];
String dto=args[2];
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo","dto",dto+".json");
if(!Files.exists(storePath))
{
String entity=dto;
if(entity.endsWith("DTO"))
entity=entity.substring(0,entity.length()-3);
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"dto",dto+".json");
if(!Files.exists(storePath))
{
EntityModel entityModel= LiteStorage.getEntityModel(system,entity);
if(entityModel!=null) {
schema= TransUtils.EntityModelModel2Schema(entityModel);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册