Skip to content

Commit 138ebd8

Browse files
dragonpooludomikula
authored andcommitted
swap ts and normal collection in api endpoint
1 parent f7a6179 commit 138ebd8

File tree

5 files changed

+34
-33
lines changed

5 files changed

+34
-33
lines changed

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/application/repository/ApplicationHistoryArchivedSnapshotRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.lowcoder.domain.application.repository;
22

3-
import org.lowcoder.domain.application.model.ApplicationHistorySnapshot;
3+
import org.lowcoder.domain.application.model.ApplicationHistorySnapshotTS;
44
import org.springframework.data.domain.Pageable;
55
import org.springframework.data.mongodb.repository.Query;
66
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
@@ -11,7 +11,7 @@
1111
import java.time.Instant;
1212

1313
@Repository
14-
public interface ApplicationHistoryArchivedSnapshotRepository extends ReactiveMongoRepository<ApplicationHistorySnapshot, String> {
14+
public interface ApplicationHistoryArchivedSnapshotRepository extends ReactiveMongoRepository<ApplicationHistorySnapshotTS, String> {
1515

1616
@Query(value = "{ 'applicationId': ?0, $and: [" +
1717
"{$or: [ { 'context.operations': { $elemMatch: { 'compName': ?1 } } }, { $expr: { $eq: [?1, null] } } ]}, " +
@@ -20,7 +20,7 @@ public interface ApplicationHistoryArchivedSnapshotRepository extends ReactiveMo
2020
"{$or: [ { 'createdAt': { $lte: ?4} }, { $expr: { $eq: [?4, null] } } ] } " +
2121
"]}",
2222
fields = "{applicationId : 1, context: 1, createdBy : 1, createdAt : 1}")
23-
Flux<ApplicationHistorySnapshot> findAllByApplicationId(String applicationId, String compName, String theme, Instant createdAtFrom, Instant createdAtTo, Pageable pageable);
23+
Flux<ApplicationHistorySnapshotTS> findAllByApplicationId(String applicationId, String compName, String theme, Instant createdAtFrom, Instant createdAtTo, Pageable pageable);
2424

2525
Mono<Long> countByApplicationId(String applicationId);
2626
}

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/application/repository/ApplicationHistorySnapshotRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.lowcoder.domain.application.repository;
22

3-
import org.lowcoder.domain.application.model.ApplicationHistorySnapshotTS;
3+
import org.lowcoder.domain.application.model.ApplicationHistorySnapshot;
44
import org.springframework.data.domain.Pageable;
55
import org.springframework.data.mongodb.repository.Query;
66
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
@@ -11,7 +11,7 @@
1111
import java.time.Instant;
1212

1313
@Repository
14-
public interface ApplicationHistorySnapshotRepository extends ReactiveMongoRepository<ApplicationHistorySnapshotTS, String> {
14+
public interface ApplicationHistorySnapshotRepository extends ReactiveMongoRepository<ApplicationHistorySnapshot, String> {
1515

1616
@Query(value = "{ 'applicationId': ?0, $and: [" +
1717
"{$or: [ { 'context.operations': { $elemMatch: { 'compName': ?1 } } }, { $expr: { $eq: [?1, null] } } ]}, " +
@@ -20,7 +20,7 @@ public interface ApplicationHistorySnapshotRepository extends ReactiveMongoRepos
2020
"{$or: [ { 'createdAt': { $lte: ?4} }, { $expr: { $eq: [?4, null] } } ] } " +
2121
"]}",
2222
fields = "{applicationId : 1, context: 1, createdBy : 1, createdAt : 1}")
23-
Flux<ApplicationHistorySnapshotTS> findAllByApplicationId(String applicationId, String compName, String theme, Instant createdAtFrom, Instant createdAtTo, Pageable pageable);
23+
Flux<ApplicationHistorySnapshot> findAllByApplicationId(String applicationId, String compName, String theme, Instant createdAtFrom, Instant createdAtTo, Pageable pageable);
2424

2525
Mono<Long> countByApplicationId(String applicationId);
2626
}

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/application/service/ApplicationHistorySnapshotService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ public interface ApplicationHistorySnapshotService {
1313

1414
Mono<Boolean> createHistorySnapshot(String applicationId, Map<String, Object> dsl, Map<String, Object> context, String userId);
1515

16-
Mono<List<ApplicationHistorySnapshotTS>> listAllHistorySnapshotBriefInfo(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest);
17-
Mono<List<ApplicationHistorySnapshot>> listAllHistorySnapshotBriefInfoArchived(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest);
16+
Mono<List<ApplicationHistorySnapshot>> listAllHistorySnapshotBriefInfo(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest);
17+
Mono<List<ApplicationHistorySnapshotTS>> listAllHistorySnapshotBriefInfoArchived(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest);
1818

1919
Mono<Long> countByApplicationId(String applicationId);
2020

21-
Mono<ApplicationHistorySnapshotTS> getHistorySnapshotDetail(String historySnapshotId);
21+
Mono<ApplicationHistorySnapshot> getHistorySnapshotDetail(String historySnapshotId);
2222

23-
Mono<ApplicationHistorySnapshot> getHistorySnapshotDetailArchived(String historySnapshotId);
23+
Mono<ApplicationHistorySnapshotTS> getHistorySnapshotDetailArchived(String historySnapshotId);
2424
}

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/application/service/impl/ApplicationHistorySnapshotServiceImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ public class ApplicationHistorySnapshotServiceImpl implements ApplicationHistory
2929

3030
@Override
3131
public Mono<Boolean> createHistorySnapshot(String applicationId, Map<String, Object> dsl, Map<String, Object> context, String userId) {
32-
ApplicationHistorySnapshotTS applicationHistorySnapshotTS = new ApplicationHistorySnapshotTS();
33-
applicationHistorySnapshotTS.setApplicationId(applicationId);
34-
applicationHistorySnapshotTS.setDsl(dsl);
35-
applicationHistorySnapshotTS.setContext(context);
36-
return repository.save(applicationHistorySnapshotTS)
32+
ApplicationHistorySnapshot applicationHistorySnapshot = new ApplicationHistorySnapshot();
33+
applicationHistorySnapshot.setApplicationId(applicationId);
34+
applicationHistorySnapshot.setDsl(dsl);
35+
applicationHistorySnapshot.setContext(context);
36+
return repository.save(applicationHistorySnapshot)
3737
.thenReturn(true)
3838
.onErrorReturn(false);
3939
}
4040

4141
@Override
42-
public Mono<List<ApplicationHistorySnapshotTS>> listAllHistorySnapshotBriefInfo(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest) {
42+
public Mono<List<ApplicationHistorySnapshot>> listAllHistorySnapshotBriefInfo(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest) {
4343
return repository.findAllByApplicationId(applicationId, compName, theme, from, to, pageRequest.withSort(Direction.DESC, "id"))
4444
.collectList()
4545
.onErrorMap(Exception.class, e -> ofException(BizError.FETCH_HISTORY_SNAPSHOT_FAILURE, "FETCH_HISTORY_SNAPSHOT_FAILURE"));
4646
}
4747

4848
@Override
49-
public Mono<List<ApplicationHistorySnapshot>> listAllHistorySnapshotBriefInfoArchived(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest) {
49+
public Mono<List<ApplicationHistorySnapshotTS>> listAllHistorySnapshotBriefInfoArchived(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest) {
5050
return repositoryArchived.findAllByApplicationId(applicationId, compName, theme, from, to, pageRequest.withSort(Direction.DESC, "id"))
5151
.collectList()
5252
.onErrorMap(Exception.class, e -> ofException(BizError.FETCH_HISTORY_SNAPSHOT_FAILURE, "FETCH_HISTORY_SNAPSHOT_FAILURE"));
@@ -61,14 +61,14 @@ public Mono<Long> countByApplicationId(String applicationId) {
6161

6262

6363
@Override
64-
public Mono<ApplicationHistorySnapshotTS> getHistorySnapshotDetail(String historySnapshotId) {
64+
public Mono<ApplicationHistorySnapshot> getHistorySnapshotDetail(String historySnapshotId) {
6565
return repository.findById(historySnapshotId)
6666
.switchIfEmpty(deferredError(INVALID_HISTORY_SNAPSHOT, "INVALID_HISTORY_SNAPSHOT", historySnapshotId));
6767
}
6868

6969

7070
@Override
71-
public Mono<ApplicationHistorySnapshot> getHistorySnapshotDetailArchived(String historySnapshotId) {
71+
public Mono<ApplicationHistorySnapshotTS> getHistorySnapshotDetailArchived(String historySnapshotId) {
7272
return repositoryArchived.findById(historySnapshotId)
7373
.switchIfEmpty(deferredError(INVALID_HISTORY_SNAPSHOT, "INVALID_HISTORY_SNAPSHOT", historySnapshotId));
7474
}

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.lowcoder.domain.application.service.ApplicationService;
1414
import org.lowcoder.domain.permission.model.ResourceAction;
1515
import org.lowcoder.domain.permission.service.ResourcePermissionService;
16+
import org.lowcoder.domain.user.model.User;
1617
import org.lowcoder.domain.user.service.UserService;
1718
import org.springframework.web.bind.annotation.PathVariable;
1819
import org.springframework.web.bind.annotation.RequestBody;
@@ -69,15 +70,15 @@ public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfo(@
6970
.flatMap(__ -> applicationHistorySnapshotService.listAllHistorySnapshotBriefInfo(applicationId, compName, theme, from, to, pagination.toPageRequest()))
7071
.flatMap(snapshotList -> {
7172
Mono<List<ApplicationHistorySnapshotBriefInfo>> snapshotBriefInfoList = multiBuild(snapshotList,
72-
ApplicationHistorySnapshotTS::getCreatedBy,
73+
ApplicationHistorySnapshot::getCreatedBy,
7374
userService::getByIds,
74-
(applicationHistorySnapshotTS, user) -> new ApplicationHistorySnapshotBriefInfo(
75-
applicationHistorySnapshotTS.getId(),
76-
applicationHistorySnapshotTS.getContext(),
77-
applicationHistorySnapshotTS.getCreatedBy(),
75+
(applicationHistorySnapshot, user) -> new ApplicationHistorySnapshotBriefInfo(
76+
applicationHistorySnapshot.getId(),
77+
applicationHistorySnapshot.getContext(),
78+
applicationHistorySnapshot.getCreatedBy(),
7879
user.getName(),
7980
user.getAvatarUrl(),
80-
applicationHistorySnapshotTS.getCreatedAt().toEpochMilli()
81+
applicationHistorySnapshot.getCreatedAt().toEpochMilli()
8182
)
8283
);
8384

@@ -106,15 +107,15 @@ public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfoAr
106107
.flatMap(__ -> applicationHistorySnapshotService.listAllHistorySnapshotBriefInfoArchived(applicationId, compName, theme, from, to, pagination.toPageRequest()))
107108
.flatMap(snapshotList -> {
108109
Mono<List<ApplicationHistorySnapshotBriefInfo>> snapshotBriefInfoList = multiBuild(snapshotList,
109-
ApplicationHistorySnapshot::getCreatedBy,
110+
ApplicationHistorySnapshotTS::getCreatedBy,
110111
userService::getByIds,
111-
(applicationHistorySnapshot, user) -> new ApplicationHistorySnapshotBriefInfo(
112-
applicationHistorySnapshot.getId(),
113-
applicationHistorySnapshot.getContext(),
114-
applicationHistorySnapshot.getCreatedBy(),
112+
(applicationHistorySnapshotTS, user) -> new ApplicationHistorySnapshotBriefInfo(
113+
applicationHistorySnapshotTS.getId(),
114+
applicationHistorySnapshotTS.getContext(),
115+
applicationHistorySnapshotTS.getCreatedBy(),
115116
user.getName(),
116117
user.getAvatarUrl(),
117-
applicationHistorySnapshot.getCreatedAt().toEpochMilli()
118+
applicationHistorySnapshotTS.getCreatedAt().toEpochMilli()
118119
)
119120
);
120121

@@ -133,7 +134,7 @@ public Mono<ResponseView<HistorySnapshotDslView>> getHistorySnapshotDsl(@PathVar
133134
.delayUntil(visitor -> resourcePermissionService.checkResourcePermissionWithError(visitor, applicationId,
134135
ResourceAction.EDIT_APPLICATIONS))
135136
.flatMap(__ -> applicationHistorySnapshotService.getHistorySnapshotDetail(snapshotId))
136-
.map(ApplicationHistorySnapshotTS::getDsl)
137+
.map(ApplicationHistorySnapshot::getDsl)
137138
.zipWhen(applicationService::getAllDependentModulesFromDsl)
138139
.map(tuple -> {
139140
Map<String, Object> applicationDsl = tuple.getT1();
@@ -155,7 +156,7 @@ public Mono<ResponseView<HistorySnapshotDslView>> getHistorySnapshotDslArchived(
155156
.delayUntil(visitor -> resourcePermissionService.checkResourcePermissionWithError(visitor, applicationId,
156157
ResourceAction.EDIT_APPLICATIONS))
157158
.flatMap(__ -> applicationHistorySnapshotService.getHistorySnapshotDetailArchived(snapshotId))
158-
.map(ApplicationHistorySnapshot::getDsl)
159+
.map(ApplicationHistorySnapshotTS::getDsl)
159160
.zipWhen(applicationService::getAllDependentModulesFromDsl)
160161
.map(tuple -> {
161162
Map<String, Object> applicationDsl = tuple.getT1();

0 commit comments

Comments
 (0)