Skip to content

Commit f77e2eb

Browse files
author
Sebastian Reid
committed
getBundles, getMarketplaceBundles, getAgencyProfileBundles API
1 parent 89d7047 commit f77e2eb

File tree

8 files changed

+242
-26
lines changed

8 files changed

+242
-26
lines changed

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/bundle/repository/BundleRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ public interface BundleRepository extends ReactiveMongoRepository<Bundle, String
2525
* Filter agency bundles from list of supplied IDs
2626
*/
2727
Flux<Bundle> findByPublicToAllIsTrueAndAgencyProfileIsTrueAndIdIn(Collection<String> ids);
28+
29+
Flux<Bundle> findByPublicToAllIsTrueAndPublicToMarketplaceIsTrue();
30+
31+
Flux<Bundle> findByPublicToAllIsTrueAndAgencyProfileIsTrue();
2832
}

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/bundle/service/BundleService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.lowcoder.domain.bundle.service;
22

3+
import org.lowcoder.domain.application.model.Application;
34
import org.lowcoder.domain.application.model.ApplicationRequestType;
45
import org.lowcoder.domain.bundle.model.Bundle;
56
import org.lowcoder.domain.bundle.model.BundleRequestType;
@@ -41,4 +42,8 @@ public interface BundleService {
4142
@NonEmptyMono
4243
@SuppressWarnings("ReactiveStreamsNullableInLambdaInTransform")
4344
Mono<Set<String>> getPublicAgencyBundleIds(Collection<String> bundleIds);
45+
46+
Flux<Bundle> findAllMarketplaceBundles();
47+
48+
Flux<Bundle> findAllAgencyProfileBundles();
4449
}

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/bundle/service/BundleServiceImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.RequiredArgsConstructor;
44
import org.apache.commons.lang3.StringUtils;
5+
import org.lowcoder.domain.application.model.Application;
56
import org.lowcoder.domain.application.model.ApplicationRequestType;
67
import org.lowcoder.domain.bundle.model.Bundle;
78
import org.lowcoder.domain.bundle.model.BundleRequestType;
@@ -163,4 +164,15 @@ public Mono<Set<String>> getPublicAgencyBundleIds(Collection<String> bundleIds)
163164
.map(HasIdAndAuditing::getId)
164165
.collect(Collectors.toSet());
165166
}
167+
168+
@Override
169+
public Flux<Bundle> findAllMarketplaceBundles() {
170+
return repository.findByPublicToAllIsTrueAndPublicToMarketplaceIsTrue();
171+
}
172+
173+
@Override
174+
public Flux<Bundle> findAllAgencyProfileBundles() {
175+
return repository.findByPublicToAllIsTrueAndAgencyProfileIsTrue();
176+
}
177+
166178
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/bundle/BundleController.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package org.lowcoder.api.bundle;
22

33
import lombok.RequiredArgsConstructor;
4-
import org.lowcoder.api.application.view.ApplicationInfoView;
5-
import org.lowcoder.api.application.view.ApplicationView;
6-
import org.lowcoder.api.bundle.view.BundlePermissionView;
74
import org.lowcoder.api.bundle.view.BundleInfoView;
5+
import org.lowcoder.api.bundle.view.BundlePermissionView;
6+
import org.lowcoder.api.bundle.view.MarketplaceBundleInfoView;
87
import org.lowcoder.api.framework.view.ResponseView;
8+
import org.lowcoder.api.home.UserHomeApiService;
99
import org.lowcoder.api.util.BusinessEventPublisher;
10-
import org.lowcoder.domain.application.model.ApplicationRequestType;
1110
import org.lowcoder.domain.application.model.ApplicationType;
1211
import org.lowcoder.domain.bundle.model.Bundle;
1312
import org.lowcoder.domain.bundle.model.BundleRequestType;
@@ -18,14 +17,10 @@
1817
import org.springframework.web.bind.annotation.RequestBody;
1918
import org.springframework.web.bind.annotation.RequestParam;
2019
import org.springframework.web.bind.annotation.RestController;
21-
import reactor.core.publisher.Flux;
2220
import reactor.core.publisher.Mono;
2321

2422
import java.util.List;
2523

26-
import static org.lowcoder.domain.application.model.ApplicationStatus.NORMAL;
27-
import static org.lowcoder.plugin.api.event.LowcoderEvent.EventType.*;
28-
import static org.lowcoder.plugin.api.event.LowcoderEvent.EventType.APPLICATION_VIEW;
2924
import static org.lowcoder.sdk.exception.BizError.INVALID_PARAMETER;
3025
import static org.lowcoder.sdk.util.ExceptionUtils.ofError;
3126

@@ -37,6 +32,7 @@ public class BundleController implements BundleEndpoints
3732
private final BundleService bundleService;
3833
private final BundleApiService bundleApiService;
3934
private final BusinessEventPublisher businessEventPublisher;
35+
private final UserHomeApiService userHomeApiService;
4036

4137
@Override
4238
public Mono<ResponseView<BundleInfoView>> create(@RequestBody CreateBundleRequest bundle) {
@@ -169,4 +165,25 @@ public Mono<ResponseView<BundleInfoView>> getAgencyProfileBundle(@PathVariable S
169165
// .delayUntil(bundleView -> businessEventPublisher.publishBundleCommonEvent(bundleView, BUNDLE_VIEW))
170166
.map(ResponseView::success);
171167
}
168+
169+
@Override
170+
public Mono<ResponseView<List<BundleInfoView>>> getBundles(@RequestParam(required = false) BundleStatus bundleStatus) {
171+
return userHomeApiService.getAllAuthorisedBundles4CurrentOrgMember(bundleStatus)
172+
.collectList()
173+
.map(ResponseView::success);
174+
}
175+
176+
@Override
177+
public Mono<ResponseView<List<MarketplaceBundleInfoView>>> getMarketplaceBundles() {
178+
return userHomeApiService.getAllMarketplaceBundles()
179+
.collectList()
180+
.map(ResponseView::success);
181+
}
182+
183+
@Override
184+
public Mono<ResponseView<List<MarketplaceBundleInfoView>>> getAgencyProfileBundles() {
185+
return userHomeApiService.getAllAgencyProfileBundles()
186+
.collectList()
187+
.map(ResponseView::success);
188+
}
172189
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/bundle/BundleEndpoints.java

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import io.swagger.v3.oas.annotations.Operation;
55
import jakarta.annotation.Nullable;
6-
import org.lowcoder.api.application.view.ApplicationView;
76
import org.lowcoder.api.bundle.view.BundleInfoView;
87
import org.lowcoder.api.bundle.view.BundlePermissionView;
8+
import org.lowcoder.api.bundle.view.MarketplaceBundleInfoView;
99
import org.lowcoder.api.framework.view.ResponseView;
1010
import org.lowcoder.domain.application.model.ApplicationType;
1111
import org.lowcoder.domain.bundle.model.Bundle;
12+
import org.lowcoder.domain.bundle.model.BundleStatus;
1213
import org.lowcoder.infra.constant.NewUrl;
1314
import org.springframework.web.bind.annotation.*;
1415
import reactor.core.publisher.Mono;
@@ -44,21 +45,21 @@ public interface BundleEndpoints
4445

4546
@Operation(
4647
tags = TAG_BUNDLE_MANAGEMENT,
47-
operationId = "recycleApplication",
48-
summary = "Move Application to bin (do not delete)",
49-
description = "Move a Lowcoder Application identified by its ID to the recycle bin without permanent deletion."
48+
operationId = "recycleBundle",
49+
summary = "Move Bundle to bin (do not delete)",
50+
description = "Move a Lowcoder Bundle identified by its ID to the recycle bin without permanent deletion."
5051
)
51-
@PutMapping("/recycle/{applicationId}")
52-
public Mono<ResponseView<Boolean>> recycle(@PathVariable String applicationId);
52+
@PutMapping("/recycle/{bundleId}")
53+
public Mono<ResponseView<Boolean>> recycle(@PathVariable String bundleId);
5354

5455
@Operation(
5556
tags = TAG_BUNDLE_MANAGEMENT,
56-
operationId = "restoreRecycledApplication",
57-
summary = "Restore recycled Application",
58-
description = "Restore a previously recycled Lowcoder Application identified by its ID"
57+
operationId = "restoreRecycledBundle",
58+
summary = "Restore recycled Bundle",
59+
description = "Restore a previously recycled Lowcoder Bundle identified by its ID"
5960
)
60-
@PutMapping("/restore/{applicationId}")
61-
public Mono<ResponseView<Boolean>> restore(@PathVariable String applicationId);
61+
@PutMapping("/restore/{bundleId}")
62+
public Mono<ResponseView<Boolean>> restore(@PathVariable String bundleId);
6263

6364
@Operation(
6465
tags = TAG_BUNDLE_MANAGEMENT,
@@ -173,7 +174,35 @@ public Mono<ResponseView<Void>> grantPermission(
173174
@GetMapping("/{bundleId}/permissions")
174175
public Mono<ResponseView<BundlePermissionView>> getBundlePermissions(@PathVariable String bundleId);
175176

176-
public record BatchAddPermissionRequest(String role, Set<String> userIds, Set<String> groupIds) {
177+
@Operation(
178+
tags = TAG_BUNDLE_MANAGEMENT,
179+
operationId = "listBundles",
180+
summary = "List Bundles of current User",
181+
description = "Retrieve a list of Lowcoder Bundles accessible by the authenticated or impersonated user."
182+
)
183+
@GetMapping("/list")
184+
public Mono<ResponseView<List<BundleInfoView>>> getBundles(@RequestParam(required = false) BundleStatus bundleStatus);
185+
186+
@Operation(
187+
tags = TAG_BUNDLE_MANAGEMENT,
188+
operationId = "listMarketplaceBundles",
189+
summary = "List Marketplace Bundles",
190+
description = "Retrieve a list of Lowcoder Bundles that are published to the Marketplace"
191+
)
192+
@GetMapping("/marketplace-bundles")
193+
public Mono<ResponseView<List<MarketplaceBundleInfoView>>> getMarketplaceBundles();
194+
195+
// Falk: why we use MarketplaceBundleInfoView for AgencyProfile?
196+
@Operation(
197+
tags = TAG_BUNDLE_MANAGEMENT,
198+
operationId = "listAgencyProfileBundles",
199+
summary = "List agency profile Bundles",
200+
description = "Retrieve a list of Lowcoder Bundles that are set as agency profiles"
201+
)
202+
@GetMapping("/agency-profiles")
203+
public Mono<ResponseView<List<MarketplaceBundleInfoView>>> getAgencyProfileBundles();
204+
205+
public record BatchAddPermissionRequest(String role, Set<String> userIds, Set<String> groupIds) {
177206
}
178207

179208
public record UpdatePermissionRequest(String role) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.lowcoder.api.bundle.view;
2+
3+
import lombok.Builder;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import org.lowcoder.domain.bundle.model.BundleStatus;
7+
8+
@Builder
9+
@Getter
10+
@Setter
11+
public class MarketplaceBundleInfoView {
12+
13+
// marketplace specific details
14+
private String title;
15+
private String description;
16+
private String category;
17+
private String image;
18+
19+
// org details
20+
private final String orgId;
21+
private final String orgName;
22+
23+
// creator info
24+
private final String creatorEmail;
25+
26+
// Bundle details
27+
private final String bundleId;
28+
private final String name;
29+
private final long createAt;
30+
private final String createBy;
31+
private final BundleStatus bundleStatus;
32+
33+
34+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.lowcoder.api.application.view.ApplicationInfoView;
66
import org.lowcoder.api.application.view.MarketplaceApplicationInfoView;
77
import org.lowcoder.api.bundle.view.BundleInfoView;
8+
import org.lowcoder.api.bundle.view.MarketplaceBundleInfoView;
89
import org.lowcoder.api.usermanagement.view.UserProfileView;
910
import org.lowcoder.domain.application.model.ApplicationStatus;
1011
import org.lowcoder.domain.application.model.ApplicationType;
@@ -30,4 +31,8 @@ Flux<ApplicationInfoView> getAllAuthorisedApplications4CurrentOrgMember(@Nullabl
3031
public Flux<MarketplaceApplicationInfoView> getAllMarketplaceApplications(@Nullable ApplicationType applicationType);
3132

3233
public Flux<MarketplaceApplicationInfoView> getAllAgencyProfileApplications(@Nullable ApplicationType applicationType);
34+
35+
Flux<MarketplaceBundleInfoView> getAllMarketplaceBundles();
36+
37+
Flux<MarketplaceBundleInfoView> getAllAgencyProfileBundles();
3338
}

0 commit comments

Comments
 (0)