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

修正加载逻辑

上级 9d4a0b8c
package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPI;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ApiEntityModel extends BaseModel{
public ApiEntityModel(ApiModel apiModel,IPSDEServiceAPI apiDataEntity)
{
this.opt=apiDataEntity;
this.api=apiModel;
this.setCodeName(apiDataEntity.getCodeName());
this.setName(apiDataEntity.getName());
this.setId(String.format("%1$s-%2$s",api.getCodeName(),apiDataEntity.getCodeName()));
}
public IPSDEServiceAPI getApiDataEntity()
{
return (IPSDEServiceAPI)opt;
}
private ApiModel api;
}
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import net.ibizsys.model.app.IPSApplication; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.service.IPSSysServiceAPI;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ApiModel extends BaseModel{ public class ApiModel extends BaseModel{
public ApiModel(IPSSysServiceAPI api)
{
this.opt=api;
this.setCodeName(api.getCodeName());
this.setName(api.getName());
apiEntities=new ArrayList<>();
if(getSysServiceApi().getPSDEServiceAPIs()!=null)
{
getSysServiceApi().getPSDEServiceAPIs().forEach(item->{
apiEntities.add(new ApiEntityModel(this,item));
});
}
}
private List<ApiEntityModel> apiEntities;
public IPSSysServiceAPI getSysServiceApi()
{
return (IPSSysServiceAPI)opt;
}
} }
package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.dataentity.IPSAppDataEntity;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class AppEntityModel extends BaseModel{
public AppEntityModel(AppModel appModel,IPSAppDataEntity appDataEntity)
{
this.opt=appDataEntity;
this.app=appModel;
this.setCodeName(appDataEntity.getCodeName());
this.setName(appDataEntity.getName());
this.setId(String.format("%1$s-%2$s",app.getCodeName(),appDataEntity.getCodeName()));
}
public IPSAppDataEntity getAppDataEntity()
{
return (IPSAppDataEntity)opt;
}
private AppModel app;
}
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.IPSApplication; import net.ibizsys.model.app.IPSApplication;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class AppModel extends BaseModel{ public class AppModel extends BaseModel{
public IPSApplication getApplication()
public AppModel(IPSApplication application)
{ {
return (IPSApplication)opt; this.opt=application;
this.setCodeName(application.getCodeName());
this.setName(application.getName());
appEntities=new ArrayList<>();
if(getApplication().getAllPSAppDataEntities()!=null)
{
getApplication().getAllPSAppDataEntities().forEach(item->{
appEntities.add(new AppEntityModel(this,item));
});
}
pages=new ArrayList<>();
if(getApplication().getAllPSAppViews()!=null)
{
getApplication().getAllPSAppViews().forEach(item->{
pages.add(new PageModel(this,item));
});
}
} }
public String getMain() private List<AppEntityModel> appEntities;
private List<PageModel> pages;
public IPSApplication getApplication()
{ {
return getApplication().getDefaultPSAppIndexView().getName(); return (IPSApplication)opt;
} }
} }
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import org.springframework.util.StringUtils;
public class BaseModel { public class BaseModel {
protected String id;
protected String codeName;
protected String name;
public String getId() {
if(StringUtils.isEmpty(id)&&(!StringUtils.isEmpty(getCodeName())))
id=this.getCodeName();
return id;
}
public <T> T setId(String id) {
this.id = id;
return (T)this;
}
public String getCodeName() {
return codeName;
}
public <T> T setCodeName(String codeName) {
this.codeName = codeName;
return (T)this;
}
public String getName() {
return name;
}
public <T> T setName(String name) {
this.name = name;
return (T)this;
}
protected Object opt; protected Object opt;
public <T> T setOpt(Object opt) public <T> T setOpt(Object opt)
......
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class CtrlModel extends BaseModel{ public class CtrlModel extends BaseModel{
......
...@@ -20,6 +20,17 @@ import net.ibizsys.model.dataentity.ds.IPSDEDataSet; ...@@ -20,6 +20,17 @@ import net.ibizsys.model.dataentity.ds.IPSDEDataSet;
@Accessors(chain = true) @Accessors(chain = true)
public class DataSetModel extends BaseModel{ public class DataSetModel extends BaseModel{
public DataSetModel(EntityModel entityModel,IPSDEDataSet dataSet)
{
this.opt=dataSet;
this.entity=entityModel;
this.setCodeName(dataSet.getCodeName());
this.setName(dataSet.getName());
this.setId(String.format("%1$s-%2$s",entity.getCodeName(),dataSet.getCodeName()));
}
private EntityModel entity;
/** /**
* 标识 * 标识
*/ */
...@@ -28,24 +39,19 @@ public class DataSetModel extends BaseModel{ ...@@ -28,24 +39,19 @@ public class DataSetModel extends BaseModel{
* 名称 * 名称
*/ */
private String datasetName; private String datasetName;
/**
* 实体标识 @Override
*/ public DataSetModel setCodeName(String codeName) {
private String entityId; super.setCodeName(codeName);
/** this.setId(String.format("%1$s-%2$s",entity.getCodeName(),codeName));
* 实体 return this;
*/ }
private String entityName;
/**
* 代码名称
*/
private String codeName;
/** /**
* 代码 * 代码
*/ */
private String dsCode; private String dsCode;
/** /**
* 模型 * SQL
*/ */
private String dsModel; private String dsModel;
......
...@@ -20,31 +20,42 @@ import java.util.Set; ...@@ -20,31 +20,42 @@ import java.util.Set;
@JsonIgnoreProperties(value = "handler") @JsonIgnoreProperties(value = "handler")
public class FieldModel extends BaseModel { public class FieldModel extends BaseModel {
public FieldModel(EntityModel entityModel,IPSDEField deField)
{
this.opt=deField;
this.entity=entityModel;
this.setCodeName(deField.getCodeName());
this.setName(deField.getName());
this.setId(String.format("%1$s-%2$s",entity.getCodeName(),deField.getCodeName()));
}
public String getCodeName() { public String getCodeName() {
return getField().getCodeName(); return getDataEntityField().getCodeName();
} }
public String getFieldName() { public String getFieldName() {
return getField().getName(); return getDataEntityField().getName();
} }
public String getLogicName() { public String getLogicName() {
return getField().getLogicName(); return getDataEntityField().getLogicName();
} }
public PropType getType() public PropType getType()
{ {
return PropType.findType(this.getField().getStdDataType()); return PropType.findType(this.getDataEntityField().getStdDataType());
} }
private String expression; private String expression;
public IPSDEField getField() public IPSDEField getDataEntityField()
{ {
return (IPSDEField)opt; return (IPSDEField)opt;
} }
private EntityModel entity;
private RelationshipModel reference; private RelationshipModel reference;
private String refFieldName; private String refFieldName;
...@@ -53,50 +64,50 @@ public class FieldModel extends BaseModel { ...@@ -53,50 +64,50 @@ public class FieldModel extends BaseModel {
public boolean isPhisicalDEField() public boolean isPhisicalDEField()
{ {
return this.getField().isPhisicalDEField(); return this.getDataEntityField().isPhisicalDEField();
} }
public boolean isKeyDEField() public boolean isKeyDEField()
{ {
return this.getField().isKeyDEField(); return this.getDataEntityField().isKeyDEField();
} }
public boolean isLogicValidField() public boolean isLogicValidField()
{ {
return "LOGICVALID".equals(this.getField().getPredefinedType()); return "LOGICVALID".equals(this.getDataEntityField().getPredefinedType());
} }
public boolean isLastModifyField() public boolean isLastModifyField()
{ {
return "UPDATEDATE".equals(this.getField().getPredefinedType()); return "UPDATEDATE".equals(this.getDataEntityField().getPredefinedType());
} }
public boolean isCreateTimeField() public boolean isCreateTimeField()
{ {
return "CREATEDATE".equals(this.getField().getPredefinedType()); return "CREATEDATE".equals(this.getDataEntityField().getPredefinedType());
} }
public boolean isUnionKeyField() public boolean isUnionKeyField()
{ {
return !StringUtils.isEmpty(this.getField().getUnionKeyValue()); return !StringUtils.isEmpty(this.getDataEntityField().getUnionKeyValue());
} }
public String getDefaultValue() public String getDefaultValue()
{ {
if((!StringUtils.isEmpty(getField().getDefaultValueType()))||(!StringUtils.isEmpty(getField().getDefaultValue()))) if((!StringUtils.isEmpty(getDataEntityField().getDefaultValueType()))||(!StringUtils.isEmpty(getDataEntityField().getDefaultValue())))
{ {
String defaultValue=""; String defaultValue="";
if(StringUtils.isEmpty(getField().getDefaultValueType())||"NONE".equalsIgnoreCase(getField().getDefaultValueType())) if(StringUtils.isEmpty(getDataEntityField().getDefaultValueType())||"NONE".equalsIgnoreCase(getDataEntityField().getDefaultValueType()))
{ {
defaultValue=getField().getDefaultValue(); defaultValue=getDataEntityField().getDefaultValue();
} }
else if(!StringUtils.isEmpty(getField().getDefaultValue())) else if(!StringUtils.isEmpty(getDataEntityField().getDefaultValue()))
{ {
defaultValue= String.format("${%1$s.%2$s}",getField().getDefaultValueType(),getField().getDefaultValue()); defaultValue= String.format("${%1$s.%2$s}",getDataEntityField().getDefaultValueType(),getDataEntityField().getDefaultValue());
} }
else else
{ {
defaultValue= String.format("${%1$s}",getField().getDefaultValueType()); defaultValue= String.format("${%1$s}",getDataEntityField().getDefaultValueType());
} }
return defaultValue; return defaultValue;
} }
...@@ -106,11 +117,11 @@ public class FieldModel extends BaseModel { ...@@ -106,11 +117,11 @@ public class FieldModel extends BaseModel {
public Set<String> getSearchMode() public Set<String> getSearchMode()
{ {
Set<String> modes=new LinkedHashSet<>(); Set<String> modes=new LinkedHashSet<>();
if(getField().getAllPSDEFSearchModes()!=null) if(getDataEntityField().getAllPSDEFSearchModes()!=null)
{ {
getField().getAllPSDEFSearchModes().forEach(item->modes.add(item.getValueOP().toLowerCase())); getDataEntityField().getAllPSDEFSearchModes().forEach(item->modes.add(item.getValueOP().toLowerCase()));
} }
if(getField().isEnableQuickSearch()) if(getDataEntityField().isEnableQuickSearch())
modes.add("query"); modes.add("query");
return modes; return modes;
} }
......
...@@ -6,9 +6,11 @@ import cn.ibizlab.codegen.CodegenConstants; ...@@ -6,9 +6,11 @@ import cn.ibizlab.codegen.CodegenConstants;
import cn.ibizlab.codegen.templating.TemplateFileType; import cn.ibizlab.codegen.templating.TemplateFileType;
import net.ibizsys.model.IPSSystem; import net.ibizsys.model.IPSSystem;
import net.ibizsys.model.PSModelServiceImpl;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
...@@ -32,11 +34,42 @@ public class ModelStorage { ...@@ -32,11 +34,42 @@ public class ModelStorage {
public ModelStorage config(CodegenConfig config) public ModelStorage config(CodegenConfig config)
{ {
this.config=config; this.config=config;
DynamicModelStorage.getInstance().modelPath(config.getInputSpec());
return this; return this;
} }
private DynamicModelStorage dynamicService=DynamicModelStorage.getInstance();
private SystemModel systemModel = null;
public SystemModel getSystemModel()
{
if(systemModel==null) {
String modelPath=config.getInputSpec();
String strPSModelFolderPath=null;
if(Files.exists(Paths.get(modelPath,"PSSYSTEM.json"))) {
strPSModelFolderPath= Paths.get(modelPath).toString();
}
else if(Files.exists(Paths.get(modelPath,"model","PSSYSTEM.json"))) {
strPSModelFolderPath= Paths.get(modelPath,"model").toString();
}
Assert.hasLength(strPSModelFolderPath,"加载系统模型错误,未找到对应模型目录");
PSModelServiceImpl psModelService = new PSModelServiceImpl();
psModelService.setPSModelFolderPath(strPSModelFolderPath);
try {
IPSSystem iPSSystem = psModelService.getPSSystem();
systemModel = new SystemModel(iPSSystem);
Assert.notNull(iPSSystem,"加载系统模型错误:"+strPSModelFolderPath);
} catch (Exception e) {
throw new RuntimeException("加载系统模型错误"+strPSModelFolderPath,e);
}
}
return systemModel;
}
...@@ -46,7 +79,7 @@ public class ModelStorage { ...@@ -46,7 +79,7 @@ public class ModelStorage {
opt.putAll(config.getAdditionalProperties()); opt.putAll(config.getAdditionalProperties());
opt.setTemplateFileType(type); opt.setTemplateFileType(type);
SystemModel systemModel=dynamicService.getSystemModel(); SystemModel systemModel=getSystemModel();
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_NAME))) if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_NAME)))
opt.setProjectName(systemModel.getProjectName()); opt.setProjectName(systemModel.getProjectName());
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_DESC))) if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_DESC)))
...@@ -69,49 +102,49 @@ public class ModelStorage { ...@@ -69,49 +102,49 @@ public class ModelStorage {
CliData rt=new CliData(); CliData rt=new CliData();
if(type.equals(TemplateFileType.api)) if(type.equals(TemplateFileType.api))
{ {
if(dynamicService.getSystemModel().getSystem().getAllPSSysServiceAPIs()!=null)
{ getSystemModel().getApis().forEach(item->{
dynamicService.getSystemModel().getSystem().getAllPSSysServiceAPIs().forEach(item->{ CliOption opt=newCliOption(TemplateFileType.api).baseData(item,item.getCodeName().toLowerCase());
CliOption opt=newCliOption(TemplateFileType.api).baseData(item,item.getCodeName().toLowerCase()); rt.addOption(opt);
});
}
else if(type.equals(TemplateFileType.apiEntity))
{
getSystemModel().getApis().forEach(api->{
api.getApiEntities().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.apiEntity).baseData(item,item.getCodeName()).set("apis",api.getCodeName().toLowerCase());
rt.addOption(opt); rt.addOption(opt);
}); });
} });
} }
else if(type.equals(TemplateFileType.app)) else if(type.equals(TemplateFileType.app))
{ {
if(dynamicService.getSystemModel().getSystem().getAllPSApps()!=null) getSystemModel().getApps().forEach(item->{
{ CliOption opt=newCliOption(TemplateFileType.app).baseData(item,item.getCodeName().toLowerCase());
dynamicService.getSystemModel().getSystem().getAllPSApps().forEach(item->{ rt.addOption(opt);
AppModel appModel=new AppModel().setOpt(item); });
CliOption opt=newCliOption(TemplateFileType.app).baseData(appModel,item.getCodeName().toLowerCase());
rt.addOption(opt);
});
}
} }
else if(type.equals(TemplateFileType.serviceApi)) else if(type.equals(TemplateFileType.appEntity))
{ {
dynamicService.getSystemModel().getSystem().getAllPSSysServiceAPIs().forEach(api->{ getSystemModel().getApps().forEach(app->{
if(api.getPSDEServiceAPIs()!=null) app.getAppEntities().forEach(item->{
{ CliOption opt=newCliOption(TemplateFileType.appEntity).baseData(item,item.getCodeName()).set("apps",app.getCodeName().toLowerCase());
api.getPSDEServiceAPIs().forEach(item->{ rt.addOption(opt);
CliOption opt=newCliOption(TemplateFileType.serviceApi).baseData(item,item.getCodeName()); });
rt.addOption(opt);
});
}
}); });
} }
else if(type.equals(TemplateFileType.entity)) else if(type.equals(TemplateFileType.entity))
{ {
dynamicService.getSystemModel().getSystem().getAllPSDataEntities().forEach(item->{ getSystemModel().getEntities().forEach(item->{
EntityModel schema=dynamicService.getEntitySchema(item.getId()); CliOption opt=newCliOption(TemplateFileType.entity).setCliSubType(item.getStorageMode()).setModule(item.getModule())
CliOption opt=newCliOption(TemplateFileType.entity).setCliSubType(schema.getStorageMode()).setModule(schema.getModule()) .baseData(item,item.getCodeName());
.baseData(schema,item.getCodeName());
rt.addOption(opt); rt.addOption(opt);
}); });
} }
else if(type.equals(TemplateFileType.module)) else if(type.equals(TemplateFileType.module))
{ {
dynamicService.getSystemModel().getSystem().getAllPSSystemModules().forEach(item->{ getSystemModel().getSystem().getAllPSSystemModules().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.module) CliOption opt=newCliOption(TemplateFileType.module)
.baseData(item,item.getCodeName()); .baseData(item,item.getCodeName());
rt.addOption(opt); rt.addOption(opt);
...@@ -119,28 +152,19 @@ public class ModelStorage { ...@@ -119,28 +152,19 @@ public class ModelStorage {
} }
else if(type.equals(TemplateFileType.page)) else if(type.equals(TemplateFileType.page))
{ {
dynamicService.getSystemModel().getSystem().getAllPSApps().forEach(app->{ getSystemModel().getApps().forEach(app->{
app.getPages().forEach(item->{
if(app.getAllPSAppViews()!=null) CliOption opt=newCliOption(TemplateFileType.page).baseData(item,item.getCodeName().toLowerCase()).set("apps",app.getCodeName().toLowerCase()).set("appModules",item.getAppModule());
{ rt.addOption(opt);
app.getAllPSAppViews().forEach(item->{ });
PageModel pageModel=new PageModel().setOpt(item);
CliOption opt=newCliOption(TemplateFileType.page)
.set("apps",app.getCodeName().toLowerCase())
.set("appModules",pageModel.getAppModule())
.baseData(pageModel,item.getCodeName().toLowerCase());
rt.addOption(opt);
});
}
}); });
} }
else if(type.equals(TemplateFileType.supportingFiles)) else if(type.equals(TemplateFileType.supportingFiles))
{ {
CliOption opt=newCliOption(TemplateFileType.supportingFiles) CliOption opt=newCliOption(TemplateFileType.supportingFiles)
.set(TemplateFileType.app.value(),getTemplateData(TemplateFileType.app)) .set(TemplateFileType.app.value(),getTemplateData(TemplateFileType.app).getOptions())
.set(TemplateFileType.api.value(),getTemplateData(TemplateFileType.api)) .set(TemplateFileType.api.value(),getTemplateData(TemplateFileType.api).getOptions())
.set(TemplateFileType.module.value(),getTemplateData(TemplateFileType.module)); .set(TemplateFileType.module.value(),getTemplateData(TemplateFileType.module).getOptions());
rt.addOption(opt); rt.addOption(opt);
} }
......
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.view.IPSAppView; import net.ibizsys.model.app.view.IPSAppView;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class PageModel extends BaseModel{ public class PageModel extends BaseModel{
public PageModel(AppModel appModel,IPSAppView appView)
{
this.opt=appView;
this.app=appModel;
this.setCodeName(appView.getCodeName());
this.setName(appView.getName());
this.setId(String.format("%1$s-%2$s",app.getCodeName(),appView.getCodeName()));
}
public IPSAppView getAppView() public IPSAppView getAppView()
{ {
return (IPSAppView)opt; return (IPSAppView)opt;
} }
private AppModel app;
public String getAppModule() public String getAppModule()
{ {
if(getAppView().getPSAppDataEntity()==null) if(getAppView().getPSAppDataEntity()==null)
......
...@@ -5,6 +5,7 @@ import lombok.Getter; ...@@ -5,6 +5,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.defield.IPSDEField;
import net.ibizsys.model.dataentity.der.IPSDERBase; import net.ibizsys.model.dataentity.der.IPSDERBase;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -16,9 +17,21 @@ import java.util.List; ...@@ -16,9 +17,21 @@ import java.util.List;
@Accessors(chain = true) @Accessors(chain = true)
public class RelationshipModel extends BaseModel{ public class RelationshipModel extends BaseModel{
private String name; public RelationshipModel(EntityModel entityModel, IPSDERBase der)
{
this.opt=der;
this.entity=entityModel;
this.setName(der.getName());
}
@Override
public RelationshipModel setCodeName(String codeName) {
super.setCodeName(codeName);
this.setId(String.format("%1$s-%2$s",entity.getCodeName(),codeName));
return this;
}
private String codeName; private EntityModel entity;
private String entityName; private String entityName;
...@@ -26,14 +39,15 @@ public class RelationshipModel extends BaseModel{ ...@@ -26,14 +39,15 @@ public class RelationshipModel extends BaseModel{
private String entityLogicName; private String entityLogicName;
private String entityId;
private String tableName; private String tableName;
private String entityId;
private String relationType; private String relationType;
public IPSDERBase getRelation() public IPSDERBase getDer()
{ {
return (IPSDERBase)opt; return (IPSDERBase)opt;
} }
......
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.templating.TemplateFileType;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.IPSSystem; import net.ibizsys.model.IPSSystem;
import net.ibizsys.model.database.IPSDEFDTColumn;
import net.ibizsys.model.dataentity.IPSDataEntity;
import net.ibizsys.model.dataentity.defield.IPSDEField;
import net.ibizsys.model.dataentity.defield.IPSLinkDEField;
import net.ibizsys.model.dataentity.der.IPSDER1N;
import net.ibizsys.model.dataentity.der.IPSDERBase;
import net.ibizsys.model.dataentity.ds.IPSDEDataQueryCode;
import net.ibizsys.model.dataentity.ds.IPSDEDataQueryCodeCond;
import net.ibizsys.model.dataentity.ds.IPSDEDataSetGroupParam;
import net.ibizsys.model.dataentity.ds.PSDEDataSetGroupParamImpl;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class SystemModel extends BaseModel { public class SystemModel extends BaseModel {
public SystemModel(IPSSystem system)
{
this.opt=system;
}
public IPSSystem getSystem() public IPSSystem getSystem()
{ {
return (IPSSystem)opt; return (IPSSystem)opt;
...@@ -24,4 +55,47 @@ public class SystemModel extends BaseModel { ...@@ -24,4 +55,47 @@ public class SystemModel extends BaseModel {
return getSystem().getCodeName().toLowerCase(); return getSystem().getCodeName().toLowerCase();
} }
private List<EntityModel> entities;
public List<EntityModel> getEntities(){
if(entities==null) {
entities = new ArrayList<>();
getSystem().getAllPSDataEntities().forEach(dataEntity -> {
entities.add(new EntityModel(dataEntity));
});
}
return entities;
}
private List<AppModel> apps;
public List<AppModel> getApps()
{
if(apps==null)
{
apps=new ArrayList<>();
if(getSystem().getAllPSApps()!=null) {
getSystem().getAllPSApps().forEach(item -> {
apps.add(new AppModel(item));
});
}
}
return apps;
}
private List<ApiModel> apis;
public List<ApiModel> getApis()
{
if(apis==null)
{
apis=new ArrayList<>();
getSystem().getAllPSSysServiceAPIs().forEach(api->{
apis.add(new ApiModel(api));
});
}
return apis;
}
} }
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import net.ibizsys.model.database.IPSDEFDTColumn;
import net.ibizsys.model.dataentity.IPSDataEntity;
import net.ibizsys.model.dataentity.defield.IPSDEField; import net.ibizsys.model.dataentity.defield.IPSDEField;
import net.ibizsys.model.dataentity.defield.IPSLinkDEField;
import net.ibizsys.model.dataentity.der.IPSDER1N;
import net.ibizsys.model.dataentity.der.IPSDERBase;
import net.ibizsys.model.dataentity.ds.IPSDEDataQueryCode;
import net.ibizsys.model.dataentity.ds.IPSDEDataQueryCodeCond;
import net.ibizsys.model.dataentity.ds.IPSDEDataSetGroupParam;
import net.ibizsys.model.dataentity.ds.PSDEDataSetGroupParamImpl;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.LinkedHashMap; import java.util.*;
import java.util.LinkedHashSet; import java.util.regex.Matcher;
import java.util.Map; import java.util.regex.Pattern;
import java.util.Set;
public class TransUtils { public class TransUtils {
private static String contextParamConvert(String contextParam)
{
String resultParam=getJavaSqlCode(contextParam).replaceAll("(IN|in) \\(\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)}\\)","$1 (\\${srf.$2.$3})");
resultParam=resultParam.replaceAll("\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)}","#{srf.$1.$2}");
resultParam=resultParam.replaceAll("\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)'\\)}","#{srf.$1.$2}");
Pattern p = Pattern.compile("srf.(datacontext|sessioncontext|webcontext).(\\w+)");
Matcher m = p.matcher(resultParam);
StringBuffer sb = new StringBuffer();
while(m.find()){
String match = m.group();
resultParam=resultParam.replace(match,match.toLowerCase());
}
resultParam=resultParam.replace("AND t11.SRFDCID = '__SRFSAASDCID__'","");
return resultParam;
}
public static String getQueryCode(IPSDEDataQueryCode dq)
{
String code=contextParamConvert(dq.getQueryCode());
if(dq.getPSDEDataQueryCodeConds()!=null)
{
int i=0;
boolean b=checkIgnoreNullvalueCond(dq.getPSDEDataQueryCodeConds());
for(IPSDEDataQueryCodeCond cond:dq.getPSDEDataQueryCodeConds())
{
if(i==0)
code=code.concat(" where ");
else if(i>0)
code=code.concat(" and ");
code=code.concat(b?checkNullContextParamConvert(cond.getCustomCond()):contextParamConvert(cond.getCustomCond()));
i++;
}
}
return code;
}
private static String getJavaSqlCode(String strSQLCode)
{
strSQLCode = strSQLCode.replace("\r\n", " ");
strSQLCode = strSQLCode.replace("\r", " ");
strSQLCode = strSQLCode.replace("\n", " ");
strSQLCode = strSQLCode.replace("\"", "\\\"");
return strSQLCode;
}
private static String checkNullContextParamConvert(String contextParam) {
String resultParam = getJavaSqlCode(contextParam).replaceAll("<#assign _value=srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)><#if _value\\?length gt 0>(.*?)\\(\\$\\{_value}\\)<#else>1=1</#if>"," ('${srf.$1.$2}'=null or '${srf.$1.$2}'='' or $4 \\${srf.$1.$2} ");
resultParam = resultParam.replaceAll("<#assign _value=srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)><#if _value\\?length gt 0>(.*?)\\$\\{_value}(.*?)?<#else>1=1</#if>", " (#{srf.$1.$2}=null or #{srf.$1.$2}='' or $4#{srf.$1.$2}$5)");
resultParam=contextParamConvert(resultParam);
return resultParam;
}
private static boolean checkIgnoreNullvalueCond(List<IPSDEDataQueryCodeCond> list)
{
if(list!=null)
{
for(IPSDEDataQueryCodeCond cond:list)
{
if(getJavaSqlCode(cond.getCustomCond()).matches("(.*?)srf(datacontext|sessioncontext|webcontext)(.*?)\\\\\"ignoreempty\\\\\":true(.*?)"))
return true;
}
}
return false;
}
public static POSchema PojoSchema2DocumentPO(PojoSchema pojoSchema) public static POSchema PojoSchema2DocumentPO(PojoSchema pojoSchema)
{ {
POSchema poSchema=new POSchema().setName(pojoSchema.getCodeName().toLowerCase()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce()) POSchema poSchema=new POSchema().setName(pojoSchema.getCodeName().toLowerCase()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce())
...@@ -128,7 +215,7 @@ public class TransUtils { ...@@ -128,7 +215,7 @@ public class TransUtils {
int order = 1; int order = 1;
for (FieldModel fieldModel : entityModel.getFields()) { for (FieldModel fieldModel : entityModel.getFields()) {
IPSDEField sub=fieldModel.getField(); IPSDEField sub=fieldModel.getDataEntityField();
String colName=fieldModel.getColumnName(dataSourceType); String colName=fieldModel.getColumnName(dataSourceType);
......
...@@ -5,7 +5,7 @@ public enum TemplateFileType { ...@@ -5,7 +5,7 @@ public enum TemplateFileType {
ctrl(Constants.CTRLS), ctrl(Constants.CTRLS),
page(Constants.PAGES), page(Constants.PAGES),
appEntity(Constants.APP_ENTITIES), appEntity(Constants.APP_ENTITIES),
serviceApi(Constants.SERVICE_APIS), apiEntity(Constants.API_ENTITIES),
entity(Constants.ENTITIES), entity(Constants.ENTITIES),
module(Constants.MODULES), module(Constants.MODULES),
api(Constants.APIS), api(Constants.APIS),
...@@ -44,7 +44,7 @@ public enum TemplateFileType { ...@@ -44,7 +44,7 @@ public enum TemplateFileType {
public static final String APIS = "apis"; public static final String APIS = "apis";
public static final String APPS = "apps"; public static final String APPS = "apps";
public static final String ENTITIES = "entities"; public static final String ENTITIES = "entities";
public static final String SERVICE_APIS = "serviceApis"; public static final String API_ENTITIES = "apiEntities";
public static final String APP_ENTITIES = "appEntities"; public static final String APP_ENTITIES = "appEntities";
public static final String MODULES = "modules"; public static final String MODULES = "modules";
public static final String PAGES = "pages"; public static final String PAGES = "pages";
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<description></description> <description></description>
<packaging>pom</packaging> <packaging>pom</packaging>
{{>../{{projectName}}-util/pom.xml}}
<parent> <parent>
<groupId>{{packageName}}</groupId> <groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-dependencies</artifactId> <artifactId>{{projectName}}-dependencies</artifactId>
......
package {{packageName}}.{{module}}.domain; package {{packageName}}.{{module}}.domain;
//{{entity.dsTypes}} {{entity.ds_types}} {{entity.dataAccCtrlArch}} // {{entity.dataAccCtrlArch}}
public class {{entity.codeName}} public class {{entity.codeName}}
{ {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册