Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,26 @@ public Class<AppTemplate> target() {
public AppTemplate convert(Object appVersion) {
return Optional.ofNullable(appVersion)
.map(ObjectUtils::<AppVersion>cast)
.map(s -> AppTemplate.builder()
.id(s.getData().getId())
.name(s.getData().getName())
.builtType(s.getData().getAppBuiltType())
.appType(s.getData().getAppType())
.category(s.getData().getAppCategory())
.attributes(s.getAttributes())
.map(appVersionObj -> AppTemplate.builder()
.id(appVersionObj.getData().getId())
.name(appVersionObj.getData().getName())
.builtType(appVersionObj.getData().getAppBuiltType())
.appType(appVersionObj.getData().getAppType())
.category(appVersionObj.getData().getAppCategory())
.attributes(appVersionObj.getAttributes())
.like(0)
.collection(0)
.usage(0)
.version("1.0.0")
.configId(s.getData().getConfigId())
.flowGraphId(s.getData().getFlowGraphId())
.createBy(s.getData().getCreateBy())
.configId(appVersionObj.getData().getConfigId())
.flowGraphId(appVersionObj.getData().getFlowGraphId())
.createBy(appVersionObj.getData().getCreateBy())
.createAt(appVersionObj.getData().getCreateAt())
.updateBy(appVersionObj.getData().getUpdateBy())
.updateAt(appVersionObj.getData().getUpdateAt())
.config(appVersionObj.getConfig())
.flowGraph(appVersionObj.getFlowGraph())
.formProperties(appVersionObj.getFormProperties())
.build())
.orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,7 @@ public TemplateInfoDto publishTemplate(TemplateAppCreateDto createDto, Operation
this.data.setAppId(newAppID);

// 只保留模板相关的属性.
this.attributes = this.attributes.entrySet()
.stream()
.filter(e -> TEMPLATE_DEFAULT_ATTRIBUTE_KEYS.contains(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
this.attributes.keySet().retainAll(TEMPLATE_DEFAULT_ATTRIBUTE_KEYS);

// 创建参数设置.
if (createDto != null) {
Expand Down Expand Up @@ -806,6 +803,7 @@ public TemplateInfoDto publishTemplate(TemplateAppCreateDto createDto, Operation
graph.setUpdateAt(now);

AppTemplate template = this.converterFactory.convert(this, AppTemplate.class);
this.templateFactory.setRepositories(template);
this.templateFactory.save(template);
String icon = this.getIcon();
if (StringUtils.isNotBlank(icon)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ public AppVersion createByTemplate(AppTemplate template, OperationContext contex
AppVersion appVersion = this.appVersionFactory.create(new AppBuilderAppPo(), this.repository);
appVersion.getData().setConfigId(template.getConfigId());
appVersion.getData().setFlowGraphId(template.getFlowGraphId());
appVersion.getData().setId(template.getId());
appVersion.cloneVersion(TemplateUtils.toAppCreateDTO(template), DEFAULT_APP_VERSION, AppTypeEnum.APP.name(),
context);
appVersion.getData().setState(AppState.INACTIVE.getName());
this.save(appVersion);
return appVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static AppBuilderApp convertToAppBuilderApp(AppTemplate template) {
.name(template.getName())
.configId(template.getConfigId())
.flowGraphId(template.getFlowGraphId())
.type(AppTypeEnum.TEMPLATE.code())
.type(AppTypeEnum.APP.code())
.appType(template.getAppType())
.version(INIT_VERSION)
.attributes(template.getAttributes())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ void testAppTemplateConvertToAppBuilderApp() {
assertThat(app).extracting(AppBuilderApp::getId,
AppBuilderApp::getVersion,
AppBuilderApp::getState,
AppBuilderApp::getType).containsExactly("123456789", "1.0.0", "inactive", "template");
AppBuilderApp::getType).containsExactly("123456789", "1.0.0", "inactive", "app");
}
}