Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit507b869

Browse files
author
Thomasr
committed
Add from-folder to application related event
1 parenta88d70f commit507b869

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

‎server/api-service/lowcoder-infra/src/main/java/org/lowcoder/infra/event/ApplicationCommonEvent.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public class ApplicationCommonEvent extends AbstractEvent {
1919
privatefinalStringfolderId;
2020
@Nullable
2121
privatefinalStringfolderName;
22+
@Nullable
23+
privatefinalStringoldFolderId;
24+
@Nullable
25+
privatefinalStringoldFolderName;
2226

2327
@Override
2428
publicEventTypegetEventType() {

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/application/ApplicationController.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public Mono<ResponseView<ApplicationView>> createFromTemplate(@RequestParam Stri
5959
publicMono<ResponseView<Boolean>>recycle(@PathVariableStringapplicationId) {
6060
returngidService.convertApplicationIdToObjectId(applicationId).flatMap(appId ->
6161
applicationApiService.recycle(appId)
62-
.delayUntil(__ ->businessEventPublisher.publishApplicationCommonEvent(applicationId,null,APPLICATION_RECYCLED))
62+
.delayUntil(__ ->businessEventPublisher.publishApplicationCommonEvent(applicationId,null,null,APPLICATION_RECYCLED))
6363
.map(ResponseView::success));
6464
}
6565

6666
@Override
6767
publicMono<ResponseView<Boolean>>restore(@PathVariableStringapplicationId) {
6868
returngidService.convertApplicationIdToObjectId(applicationId).flatMap(appId ->
6969
applicationApiService.restore(appId)
70-
.delayUntil(__ ->businessEventPublisher.publishApplicationCommonEvent(applicationId,null,APPLICATION_RESTORE))
70+
.delayUntil(__ ->businessEventPublisher.publishApplicationCommonEvent(applicationId,null,null,APPLICATION_RESTORE))
7171
.map(ResponseView::success));
7272
}
7373

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/application/view/ApplicationInfoView.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class ApplicationInfoView {
2929
privatefinalObjectcontainerSize;// for module size
3030
@Nullable
3131
privateStringfolderId;
32+
@Nullable
33+
@JsonInclude(Include.NON_NULL)
34+
privateStringfolderIdFrom;
3235

3336
@Nullable
3437
privatefinalInstantlastViewTime;// user last visit time for this app

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/home/FolderController.java‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
packageorg.lowcoder.api.home;
22

3-
importstaticorg.lowcoder.plugin.api.event.LowcoderEvent.EventType.APPLICATION_MOVE;
4-
importstaticorg.lowcoder.sdk.exception.BizError.INVALID_PARAMETER;
5-
importstaticorg.lowcoder.sdk.util.ExceptionUtils.ofError;
6-
3+
importlombok.RequiredArgsConstructor;
74
importorg.lowcoder.api.application.view.ApplicationPermissionView;
85
importorg.lowcoder.api.framework.view.PageResponseView;
96
importorg.lowcoder.api.framework.view.ResponseView;
107
importorg.lowcoder.api.util.BusinessEventPublisher;
118
importorg.lowcoder.api.util.GidService;
129
importorg.lowcoder.domain.application.model.ApplicationType;
1310
importorg.lowcoder.domain.folder.model.Folder;
11+
importorg.lowcoder.domain.folder.service.FolderElementRelationService;
1412
importorg.lowcoder.domain.folder.service.FolderService;
1513
importorg.lowcoder.domain.permission.model.ResourceRole;
1614
importorg.lowcoder.plugin.api.event.LowcoderEvent.EventType;
1715
importorg.springframework.web.bind.annotation.PathVariable;
1816
importorg.springframework.web.bind.annotation.RequestBody;
1917
importorg.springframework.web.bind.annotation.RequestParam;
2018
importorg.springframework.web.bind.annotation.RestController;
21-
22-
importlombok.RequiredArgsConstructor;
2319
importreactor.core.publisher.Mono;
2420

21+
importjava.util.List;
22+
23+
importstaticorg.lowcoder.plugin.api.event.LowcoderEvent.EventType.APPLICATION_MOVE;
24+
importstaticorg.lowcoder.sdk.exception.BizError.INVALID_PARAMETER;
25+
importstaticorg.lowcoder.sdk.util.ExceptionUtils.ofError;
26+
2527
@RequiredArgsConstructor
2628
@RestController
2729
publicclassFolderControllerimplementsFolderEndpoints
@@ -31,6 +33,7 @@ public class FolderController implements FolderEndpoints
3133
privatefinalFolderApiServicefolderApiService;
3234
privatefinalBusinessEventPublisherbusinessEventPublisher;
3335
privatefinalGidServicegidService;
36+
privatefinalFolderElementRelationServicefolderElementRelationService;
3437

3538
@Override
3639
publicMono<ResponseView<FolderInfoView>>create(@RequestBodyFolderfolder) {
@@ -89,10 +92,11 @@ public Mono<PageResponseView<?>> getElements(@RequestParam(value = "id", require
8992
@Override
9093
publicMono<ResponseView<Void>>move(@PathVariable("id")StringapplicationLikeId,
9194
@RequestParam(value ="targetFolderId",required =false)StringtargetFolderId) {
92-
returngidService.convertFolderIdToObjectId(targetFolderId).flatMap(objectId ->
93-
folderApiService.move(applicationLikeId,objectId.orElse(null))
94-
.then(businessEventPublisher.publishApplicationCommonEvent(applicationLikeId,objectId.orElse(null),APPLICATION_MOVE))
95-
.then(Mono.fromSupplier(() ->ResponseView.success(null))));
95+
returnfolderElementRelationService.getByElementIds(List.of(applicationLikeId)).next().flatMap(folderElement ->
96+
gidService.convertFolderIdToObjectId(targetFolderId).flatMap(objectId ->
97+
folderApiService.move(applicationLikeId,objectId.orElse(null))
98+
.then(businessEventPublisher.publishApplicationCommonEvent(applicationLikeId,folderElement.folderId(),objectId.orElse(null),APPLICATION_MOVE))
99+
.then(Mono.fromSupplier(() ->ResponseView.success(null)))));
96100
}
97101

98102
@Override

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/util/BusinessEventPublisher.java‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ public Mono<Void> publishFolderCommonEvent(String folderId, String folderName, E
9797
});
9898
}
9999

100-
publicMono<Void>publishApplicationCommonEvent(StringapplicationId,@NullableStringfolderId,EventTypeeventType) {
100+
publicMono<Void>publishApplicationCommonEvent(StringapplicationId,@NullableStringfolderIdFrom,@NullableStringfolderId,EventTypeeventType) {
101101
returnapplicationService.findByIdWithoutDsl(applicationId)
102102
.map(application -> {
103103
ApplicationInfoViewapplicationInfoView =ApplicationInfoView.builder()
104104
.applicationId(applicationId)
105105
.name(application.getName())
106106
.folderId(folderId)
107+
.folderIdFrom(folderIdFrom)
107108
.build();
108109
returnApplicationView.builder()
109110
.applicationInfoView(applicationInfoView)
@@ -129,6 +130,15 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
129130
.map(Optional::of)
130131
.onErrorReturn(Optional.empty());
131132
}))
133+
.zipWith(Mono.defer(() -> {
134+
StringfolderId =applicationView.getApplicationInfoView().getFolderIdFrom();
135+
if (StringUtils.isBlank(folderId)) {
136+
returnMono.just(Optional.<Folder>empty());
137+
}
138+
returnfolderService.findById(folderId)
139+
.map(Optional::of)
140+
.onErrorReturn(Optional.empty());
141+
}),TupleUtils::merge)
132142
.zipWith(sessionUserService.getVisitorToken())
133143
.zipWith(Mono.defer(() -> {
134144
StringappId =applicationView.getApplicationInfoView().getApplicationId();
@@ -144,6 +154,7 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
144154
.doOnNext(tuple -> {
145155
OrgMemberorgMember =tuple.getT1().getT1();
146156
Optional<Folder>optional =tuple.getT1().getT2();
157+
Optional<Folder>optionalFrom =tuple.getT1().getT3();
147158
Stringtoken =tuple.getT2();
148159
Stringcategory =tuple.getT3().getLeft();
149160
Stringdescription =tuple.getT3().getRight();
@@ -159,6 +170,8 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
159170
.type(eventType)
160171
.folderId(optional.map(Folder::getId).orElse(null))
161172
.folderName(optional.map(Folder::getName).orElse(null))
173+
.oldFolderId(optionalFrom.map(Folder::getId).orElse(null))
174+
.oldFolderName(optionalFrom.map(Folder::getName).orElse(null))
162175
.isAnonymous(anonymous)
163176
.sessionHash(Hashing.sha512().hashString(token,StandardCharsets.UTF_8).toString())
164177
.build();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp