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

整改ctrl逻辑

上级 af5a867a
......@@ -6,8 +6,7 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.service.IPSSysServiceAPI;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Getter
@Setter
......@@ -20,20 +19,31 @@ public class ApiModel extends BaseModel{
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));
apiEntitiesMap.put(item.getCodeName(),new ApiEntityModel(this, item));
});
}
}
private List<ApiEntityModel> apiEntities;
private SystemModel system;
public IPSSysServiceAPI getSysServiceApi()
{
return (IPSSysServiceAPI)opt;
}
private Map<String,ApiEntityModel> apiEntitiesMap=new LinkedHashMap<>();
public Collection<ApiEntityModel> getApiEntities() {
return apiEntitiesMap.values();
}
public ApiEntityModel getApiEntity(String codeName)
{
return apiEntitiesMap.get(codeName);
}
}
......@@ -6,6 +6,8 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.dataentity.IPSAppDataEntity;
import java.util.*;
@Getter
@Setter
@NoArgsConstructor
......@@ -19,6 +21,7 @@ public class AppEntityModel extends BaseModel{
this.setCodeName(appDataEntity.getCodeName());
this.setName(appDataEntity.getName());
this.setId(String.format("%1$s-%2$s",app.getCodeName(),appDataEntity.getCodeName()));
}
public IPSAppDataEntity getAppDataEntity()
......@@ -28,4 +31,18 @@ public class AppEntityModel extends BaseModel{
private AppModel app;
public Map<String,CtrlModel> ctrlsMap=new LinkedHashMap();
public AppEntityModel addCtrl(String codeName,CtrlModel ctrlModel)
{
if(!ctrlsMap.containsKey(codeName))
ctrlsMap.put(codeName,ctrlModel);
return this;
}
public Collection<CtrlModel> getCtrls()
{
return ctrlsMap.values();
}
}
......@@ -6,8 +6,7 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.IPSApplication;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Getter
@Setter
......@@ -20,31 +19,62 @@ public class AppModel extends BaseModel{
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));
appEntitiesMap.put(item.getCodeName(),new AppEntityModel(this,item));
});
}
pages=new ArrayList<>();
if(getApplication().getAllPSAppViews()!=null)
{
getApplication().getAllPSAppViews().forEach(item->{
pages.add(new PageModel(this,item));
pagesMap.put(item.getCodeName(),new PageModel(this,item));
});
}
}
private List<AppEntityModel> appEntities;
}
private List<PageModel> pages;
private SystemModel system;
public IPSApplication getApplication()
{
return (IPSApplication)opt;
}
private Map<String,AppEntityModel> appEntitiesMap=new LinkedHashMap<>();;
private Map<String,PageModel> pagesMap=new LinkedHashMap<>();
private Map<String,CtrlModel> ctrlsMap=new LinkedHashMap<>();
public Collection<AppEntityModel> getAppEntities() {
return appEntitiesMap.values();
}
public Collection<PageModel> getPages() {
return pagesMap.values();
}
public Collection<CtrlModel> getCtrls() {
return ctrlsMap.values();
}
public PageModel getPage(String codeName)
{
if(pagesMap!=null)
return pagesMap.get(codeName);
return null;
}
public AppEntityModel getAppEntity(String codeName)
{
if(appEntitiesMap!=null)
return appEntitiesMap.get(codeName);
return null;
}
}
......@@ -16,6 +16,7 @@ public class BaseModel {
return id;
}
public <T> T setId(String id) {
this.id = id;
return (T)this;
......@@ -72,4 +73,5 @@ public class BaseModel {
this.extParams = extParams;
return (T)this;
}
}
......@@ -40,13 +40,13 @@ public class CliOption extends DataObj
return this.cliSubType;
}
public CliOption baseData(Object baseData,String name)
public CliOption baseData(Object baseData,String path)
{
Assert.notNull(templateFileType,"模板类型为空");
this.set(templateFileType.name(),baseData);
this.set(templateFileType.value(),name);
this.set(templateFileType.value(),path);
if(!StringUtils.isEmpty(this.cliSubType))
this.set(templateFileType.value()+"#"+this.cliSubType,name);
this.set(templateFileType.value()+"#"+this.cliSubType,path);
return this;
}
......
......@@ -5,6 +5,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.control.IPSControl;
@Getter
@Setter
......@@ -12,6 +13,30 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class CtrlModel extends BaseModel{
public CtrlModel(AppModel appModel,IPSControl psControl)
{
this.opt=psControl;
this.app=appModel;
this.setCodeName(psControl.getCodeName());
this.setName(psControl.getName());
if(psControl.getPSAppDataEntity()!=null)
folder=psControl.getPSAppDataEntity().getCodeName();
else
folder="app";
this.setId(String.format("%1$s-%2$s-%3$s",app.getCodeName(),folder,psControl.getCodeName()));
}
private AppModel app;
private AppEntityModel appEntity;
private String folder;
public IPSControl getControl()
{
return (IPSControl)opt;
}
}
......@@ -159,6 +159,15 @@ public class ModelStorage {
});
});
}
else if(type.equals(TemplateFileType.ctrl))
{
getSystemModel().getApps().forEach(app->{
app.getCtrls().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.ctrl).baseData(item,item.getCodeName().toLowerCase()).set("apps",app.getCodeName().toLowerCase()).set("appEntities",item.getFolder().toLowerCase());
rt.addOption(opt);
});
});
}
else if(type.equals(TemplateFileType.supportingFiles))
{
CliOption opt=newCliOption(TemplateFileType.supportingFiles)
......
......@@ -7,6 +7,8 @@ import lombok.experimental.Accessors;
import net.ibizsys.model.app.view.IPSAppView;
import org.springframework.util.StringUtils;
import java.util.*;
@Getter
@Setter
@NoArgsConstructor
......@@ -20,6 +22,27 @@ public class PageModel extends BaseModel{
this.setCodeName(appView.getCodeName());
this.setName(appView.getName());
this.setId(String.format("%1$s-%2$s",app.getCodeName(),appView.getCodeName()));
if(appView.getPSAppDataEntity()!=null)
this.appEntity=app.getAppEntity(appView.getPSAppDataEntity().getCodeName());
if(appView.getPSControls()!=null)
{
appView.getPSControls().forEach(item->{
CtrlModel ctrl=new CtrlModel(appModel,item);
if(!this.app.getCtrlsMap().containsKey(ctrl.getId()))
{
if(ctrl.getControl().getPSAppDataEntity()!=null) {
AppEntityModel ctrlAppEntity=app.getAppEntity(ctrl.getControl().getPSAppDataEntity().getCodeName());
ctrl.setAppEntity(ctrlAppEntity);
ctrlAppEntity.addCtrl(ctrl.getCodeName(),ctrl);
}
this.app.getCtrlsMap().put(ctrl.getId(),ctrl);
this.ctrlsMap.put(ctrl.getCodeName(),ctrl);
}
});
}
}
public IPSAppView getAppView()
......@@ -29,6 +52,8 @@ public class PageModel extends BaseModel{
private AppModel app;
private AppEntityModel appEntity;
public String getAppModule()
{
if(getAppView().getPSAppDataEntity()==null)
......@@ -39,5 +64,11 @@ public class PageModel extends BaseModel{
return appModules;
}
private Map<String,CtrlModel> ctrlsMap=new LinkedHashMap<>();
public Collection<CtrlModel> getCtrls(){
return ctrlsMap.values();
}
}
......@@ -55,47 +55,65 @@ public class SystemModel extends BaseModel {
return getSystem().getCodeName().toLowerCase();
}
private List<EntityModel> entities;
public List<EntityModel> getEntities(){
if(entities==null) {
entities = new ArrayList<>();
private Map<String,EntityModel> entitiesMap;
public synchronized Map<String, EntityModel> getEntitiesMap() {
if(entitiesMap==null) {
entitiesMap = new LinkedHashMap<>();
getSystem().getAllPSDataEntities().forEach(dataEntity -> {
entities.add(new EntityModel(dataEntity));
entitiesMap.put(dataEntity.getCodeName(),new EntityModel(dataEntity));
});
}
return entities;
return entitiesMap;
}
private List<AppModel> apps;
public List<AppModel> getApps()
{
if(apps==null)
public Collection<EntityModel> getEntities(){
return getEntitiesMap().values();
}
private Map<String,AppModel> appsMap;
public synchronized Map<String, AppModel> getAppsMap() {
if(appsMap==null)
{
apps=new ArrayList<>();
appsMap=new LinkedHashMap<>();
if(getSystem().getAllPSApps()!=null) {
getSystem().getAllPSApps().forEach(item -> {
apps.add(new AppModel(item));
appsMap.put(item.getCodeName(),new AppModel(item).setSystem(this));
});
}
}
return apps;
return appsMap;
}
private List<ApiModel> apis;
public List<ApiModel> getApis()
public Collection<AppModel> getApps()
{
if(apis==null)
return getAppsMap().values();
}
private Map<String,ApiModel> apisMap;
public synchronized Map<String, ApiModel> getApisMap() {
if(apisMap==null)
{
apis=new ArrayList<>();
apisMap=new LinkedHashMap<>();
getSystem().getAllPSSysServiceAPIs().forEach(api->{
apis.add(new ApiModel(api));
apisMap.put(api.getCodeName(),new ApiModel(api).setSystem(this));
});
}
return apis;
return apisMap;
}
public Collection<ApiModel> getApis()
{
return getApisMap().values();
}
public EntityModel getEntity(String codeName)
{
return getEntitiesMap().get(codeName);
}
}
{{page.codeName}}--{{page.appModule}}
{{#page.ctrls}}
这里是页面视图 ctrl的代码名称 {{codeName}}
{{/page.ctrls}}
这里是页面视图所属应用实体的代码名称{{page.appEntity.codeName}}
\ No newline at end of file
{{#appEntity.ctrls}}
这里是应用实体ctrl的代码名称 {{codeName}}
{{/appEntity.ctrls}}
\ No newline at end of file
{{ctrl.name}}
这里是部件所属应用实体的代码名称{{ctrl.appEntity.codeName}}
\ No newline at end of file
......@@ -9,7 +9,7 @@
<name>{{projectDesc}}</name>
<description></description>
<packaging>pom</packaging>
{{> {{{{projectName}}}}-util/pom.xml}}
<parent>
<groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-dependencies</artifactId>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册