Skip to content

Commit 4b4999d

Browse files
lizhichao51lizhichao51
andauthored
[app-platform] 修复模板相关逻辑 (#258)
Co-authored-by: lizhichao51 <[email protected]>
1 parent 0ffca2b commit 4b4999d

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/converters/impl/AppVersionToTemplateConverter.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,26 @@ public Class<AppTemplate> target() {
3636
public AppTemplate convert(Object appVersion) {
3737
return Optional.ofNullable(appVersion)
3838
.map(ObjectUtils::<AppVersion>cast)
39-
.map(s -> AppTemplate.builder()
40-
.id(s.getData().getId())
41-
.name(s.getData().getName())
42-
.builtType(s.getData().getAppBuiltType())
43-
.appType(s.getData().getAppType())
44-
.category(s.getData().getAppCategory())
45-
.attributes(s.getAttributes())
39+
.map(appVersionObj -> AppTemplate.builder()
40+
.id(appVersionObj.getData().getId())
41+
.name(appVersionObj.getData().getName())
42+
.builtType(appVersionObj.getData().getAppBuiltType())
43+
.appType(appVersionObj.getData().getAppType())
44+
.category(appVersionObj.getData().getAppCategory())
45+
.attributes(appVersionObj.getAttributes())
4646
.like(0)
4747
.collection(0)
4848
.usage(0)
4949
.version("1.0.0")
50-
.configId(s.getData().getConfigId())
51-
.flowGraphId(s.getData().getFlowGraphId())
52-
.createBy(s.getData().getCreateBy())
50+
.configId(appVersionObj.getData().getConfigId())
51+
.flowGraphId(appVersionObj.getData().getFlowGraphId())
52+
.createBy(appVersionObj.getData().getCreateBy())
53+
.createAt(appVersionObj.getData().getCreateAt())
54+
.updateBy(appVersionObj.getData().getUpdateBy())
55+
.updateAt(appVersionObj.getData().getUpdateAt())
56+
.config(appVersionObj.getConfig())
57+
.flowGraph(appVersionObj.getFlowGraph())
58+
.formProperties(appVersionObj.getFormProperties())
5359
.build())
5460
.orElse(null);
5561
}

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/domains/appversion/AppVersion.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,10 +771,7 @@ public TemplateInfoDto publishTemplate(TemplateAppCreateDto createDto, Operation
771771
this.data.setAppId(newAppID);
772772

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

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

808805
AppTemplate template = this.converterFactory.convert(this, AppTemplate.class);
806+
this.templateFactory.setRepositories(template);
809807
this.templateFactory.save(template);
810808
String icon = this.getIcon();
811809
if (StringUtils.isNotBlank(icon)) {

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/domains/appversion/service/impl/AppVersionServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ public AppVersion createByTemplate(AppTemplate template, OperationContext contex
237237
AppVersion appVersion = this.appVersionFactory.create(new AppBuilderAppPo(), this.repository);
238238
appVersion.getData().setConfigId(template.getConfigId());
239239
appVersion.getData().setFlowGraphId(template.getFlowGraphId());
240+
appVersion.getData().setId(template.getId());
240241
appVersion.cloneVersion(TemplateUtils.toAppCreateDTO(template), DEFAULT_APP_VERSION, AppTypeEnum.APP.name(),
241242
context);
243+
appVersion.getData().setState(AppState.INACTIVE.getName());
242244
this.save(appVersion);
243245
return appVersion;
244246
}

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/util/TemplateUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static AppBuilderApp convertToAppBuilderApp(AppTemplate template) {
9595
.name(template.getName())
9696
.configId(template.getConfigId())
9797
.flowGraphId(template.getFlowGraphId())
98-
.type(AppTypeEnum.TEMPLATE.code())
98+
.type(AppTypeEnum.APP.code())
9999
.appType(template.getAppType())
100100
.version(INIT_VERSION)
101101
.attributes(template.getAttributes())

app-builder/jane/plugins/aipp-plugin/src/test/java/modelengine/fit/jober/aipp/util/TemplateUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ void testAppTemplateConvertToAppBuilderApp() {
5454
assertThat(app).extracting(AppBuilderApp::getId,
5555
AppBuilderApp::getVersion,
5656
AppBuilderApp::getState,
57-
AppBuilderApp::getType).containsExactly("123456789", "1.0.0", "inactive", "template");
57+
AppBuilderApp::getType).containsExactly("123456789", "1.0.0", "inactive", "app");
5858
}
5959
}

0 commit comments

Comments
 (0)