Skip to content

Commit 060851e

Browse files
committed
PTM apps enhancements
1 parent e5f2d29 commit 060851e

File tree

11 files changed

+60
-8
lines changed

11 files changed

+60
-8
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public interface ApplicationRepository extends ReactiveMongoRepository<Applicati
3838
Flux<Application> findByPublicToAllIsTrueAndPublicToMarketplaceIsOrAgencyProfileIsAndIdIn
3939
(Boolean publicToMarketplace, Boolean agencyProfile, Collection<String> ids);
4040

41+
Flux<Application> findByPublicToAllIsTrueAndPublicToMarketplaceIsAndAgencyProfileIsAndIdIn(Boolean publicToMarketplace, Boolean agencyProfile, Collection<String> ids);
42+
4143
Flux<Application> findByPublicToAllIsTrueAndPublicToMarketplaceIsTrue();
4244

4345
Flux<Application> findByPublicToAllIsTrueAndAgencyProfileIsTrue();

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

+18-4
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,24 @@ public Mono<Boolean> setApplicationAsAgencyProfile(String applicationId, boolean
198198

199199
@NonEmptyMono
200200
@SuppressWarnings("ReactiveStreamsNullableInLambdaInTransform")
201-
public Mono<Set<String>> getPublicApplicationIds(Collection<String> applicationIds, Boolean isAnonymous) {
202-
return repository.findByPublicToAllIsTrueAndPublicToMarketplaceIsOrAgencyProfileIsAndIdIn(!isAnonymous, !isAnonymous, applicationIds)
203-
.map(HasIdAndAuditing::getId)
204-
.collect(Collectors.toSet());
201+
public Mono<Set<String>> getPublicApplicationIds(Collection<String> applicationIds, Boolean isAnonymous, Boolean isPrivateMarketplace) {
202+
203+
if(isAnonymous) {
204+
if(isPrivateMarketplace) {
205+
return repository.findByPublicToAllIsTrueAndPublicToMarketplaceIsAndAgencyProfileIsAndIdIn(false, false, applicationIds)
206+
.map(HasIdAndAuditing::getId)
207+
.collect(Collectors.toSet());
208+
} else {
209+
return repository.findByPublicToAllIsTrueAndPublicToMarketplaceIsAndAgencyProfileIsAndIdIn(true, false, applicationIds)
210+
.map(HasIdAndAuditing::getId)
211+
.collect(Collectors.toSet());
212+
}
213+
} else {
214+
return repository.findByPublicToAllIsTrueAndPublicToMarketplaceIsOrAgencyProfileIsAndIdIn(true, true, applicationIds)
215+
.map(HasIdAndAuditing::getId)
216+
.collect(Collectors.toSet());
217+
}
218+
205219

206220
}
207221
}

‎server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/permission/service/ApplicationPermissionHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected Mono<Map<String, List<ResourcePermission>>> getAnonymousUserPermission
4646
}
4747

4848
Set<String> applicationIds = newHashSet(resourceIds);
49-
return Mono.zip(applicationService.getPublicApplicationIds(applicationIds, Boolean.TRUE),
49+
return Mono.zip(applicationService.getPublicApplicationIds(applicationIds, Boolean.TRUE, config.getMarketplace().isPrivateMode()),
5050
templateSolution.getTemplateApplicationIds(applicationIds))
5151
.map(tuple -> {
5252
Set<String> publicAppIds = tuple.getT1();
@@ -61,7 +61,7 @@ protected Mono<Map<String, List<ResourcePermission>>> getAnonymousUserPermission
6161
(Collection<String> resourceIds, ResourceAction resourceAction) {
6262

6363
Set<String> applicationIds = newHashSet(resourceIds);
64-
return Mono.zip(applicationService.getPublicApplicationIds(applicationIds, Boolean.FALSE),
64+
return Mono.zip(applicationService.getPublicApplicationIds(applicationIds, Boolean.FALSE, config.getMarketplace().isPrivateMode()),
6565
templateSolution.getTemplateApplicationIds(applicationIds))
6666
.map(tuple -> {
6767
Set<String> publicAppIds = tuple.getT1();

‎server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/permission/service/ResourcePermissionHandler.java

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.lowcoder.domain.permission.model.ResourceRole;
2727
import org.lowcoder.domain.permission.model.ResourceType;
2828
import org.lowcoder.domain.permission.model.UserPermissionOnResourceStatus;
29+
import org.lowcoder.sdk.config.CommonConfig;
2930
import org.springframework.beans.factory.annotation.Autowired;
3031

3132
import com.google.common.collect.Maps;
@@ -44,6 +45,9 @@ abstract class ResourcePermissionHandler {
4445
@Autowired
4546
private OrgMemberService orgMemberService;
4647

48+
@Autowired
49+
protected CommonConfig config;
50+
4751
public Mono<Map<String, List<ResourcePermission>>> getAllMatchingPermissions(String userId,
4852
Collection<String> resourceIds,
4953
ResourceAction resourceAction) {

‎server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/config/CommonConfig.java

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class CommonConfig {
4444
private Cookie cookie = new Cookie();
4545
private JsExecutor jsExecutor = new JsExecutor();
4646
private Set<String> disallowedHosts = new HashSet<>();
47+
private Marketplace marketplace = new Marketplace();
4748

4849
public boolean isSelfHost() {
4950
return !isCloud();
@@ -145,6 +146,12 @@ public static class JsExecutor {
145146
private String host;
146147
}
147148

149+
@Data
150+
public static class Marketplace {
151+
152+
private boolean privateMode = Boolean.TRUE;
153+
}
154+
148155

149156
@Getter
150157
@Setter

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public Mono<ResponseView<List<MarketplaceApplicationInfoView>>> getMarketplaceAp
155155
@Override
156156
public Mono<ResponseView<List<MarketplaceApplicationInfoView>>> getAgencyProfileApplications(@RequestParam(required = false) Integer applicationType) {
157157
ApplicationType applicationTypeEnum = applicationType == null ? null : ApplicationType.fromValue(applicationType);
158-
return userHomeApiService.getAllMarketplaceApplications(applicationTypeEnum)
158+
return userHomeApiService.getAllAgencyProfileApplications(applicationTypeEnum)
159159
.collectList()
160160
.map(ResponseView::success);
161161
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
import lombok.Builder;
44
import lombok.Getter;
5+
import lombok.Setter;
56
import org.lowcoder.domain.application.model.ApplicationStatus;
67

78
@Builder
89
@Getter
10+
@Setter
911
public class MarketplaceApplicationInfoView {
1012

13+
// marketplace specific details
14+
private String title;
15+
private String description;
16+
private String category;
17+
1118
// org details
1219
private final String orgId;
1320
private final String orgName;

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/security/SecurityConfig.java

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
108108
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, CONFIG_URL), // system config
109109
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, CONFIG_URL + "/deploymentId"), // system config
110110
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, APPLICATION_URL + "/*/view"), // application view
111+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, APPLICATION_URL + "/*/view_marketplace"), // application view
111112
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, USER_URL + "/me"),
112113
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, USER_URL + "/currentUser"),
113114

@@ -132,6 +133,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
132133
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.CONFIG_URL + "/deploymentId"),
133134
ServerWebExchangeMatchers.pathMatchers(HttpMethod.HEAD, NewUrl.STATE_URL + "/healthCheck"),
134135
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.APPLICATION_URL + "/*/view"),
136+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.APPLICATION_URL + "/*/view_marketplace"),
135137
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.USER_URL + "/me"),
136138
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.USER_URL + "/currentUser"),
137139
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.GROUP_URL + "/list"),
@@ -177,6 +179,7 @@ private CorsConfigurationSource buildCorsConfigurationSource() {
177179
source.registerCorsConfiguration(GROUP_URL + "/list", skipCheckCorsForAll);
178180
source.registerCorsConfiguration(QUERY_URL + "/execute", skipCheckCorsForAll);
179181
source.registerCorsConfiguration(APPLICATION_URL + "/*/view", skipCheckCorsForAll);
182+
source.registerCorsConfiguration(APPLICATION_URL + "/*/view_marketplace", skipCheckCorsForAll);
180183
source.registerCorsConfiguration(GITHUB_STAR, skipCheckCorsForAll);
181184
source.registerCorsConfiguration(ORGANIZATION_URL + "/*/datasourceTypes", skipCheckCorsForAll);
182185
source.registerCorsConfiguration(DATASOURCE_URL + "/jsDatasourcePlugins", skipCheckCorsForAll);
@@ -186,6 +189,7 @@ private CorsConfigurationSource buildCorsConfigurationSource() {
186189
source.registerCorsConfiguration(NewUrl.GROUP_URL + "/list", skipCheckCorsForAll);
187190
source.registerCorsConfiguration(NewUrl.QUERY_URL + "/execute", skipCheckCorsForAll);
188191
source.registerCorsConfiguration(NewUrl.APPLICATION_URL + "/*/view", skipCheckCorsForAll);
192+
source.registerCorsConfiguration(NewUrl.APPLICATION_URL + "/*/view_marketplace", skipCheckCorsForAll);
189193
source.registerCorsConfiguration(NewUrl.ORGANIZATION_URL + "/*/datasourceTypes", skipCheckCorsForAll);
190194
source.registerCorsConfiguration(NewUrl.DATASOURCE_URL + "/jsDatasourcePlugins", skipCheckCorsForAll);
191195

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public Flux<MarketplaceApplicationInfoView> getAllMarketplaceApplications(@Nulla
292292
Application application = tuple.getT1();
293293
Map<String, User> userMap = tuple.getT2();
294294
Map<String, Organization> orgMap = tuple.getT3();
295-
return MarketplaceApplicationInfoView.builder()
295+
MarketplaceApplicationInfoView marketplaceApplicationInfoView = MarketplaceApplicationInfoView.builder()
296296
.applicationId(application.getId())
297297
.name(application.getName())
298298
.applicationType(application.getApplicationType())
@@ -305,6 +305,16 @@ public Flux<MarketplaceApplicationInfoView> getAllMarketplaceApplications(@Nulla
305305
.createAt(application.getCreatedAt().toEpochMilli())
306306
.createBy(application.getCreatedBy())
307307
.build();
308+
309+
// marketplace specific fields
310+
Map<String, Object> marketplaceMeta = (Map<String, Object>)
311+
((Map<String, Object>)application.getEditingApplicationDSL().get("ui")).get("marketplaceMeta");
312+
marketplaceApplicationInfoView.setTitle((String)marketplaceMeta.get("title"));
313+
marketplaceApplicationInfoView.setCategory((String)marketplaceMeta.get("category"));
314+
marketplaceApplicationInfoView.setDescription((String)marketplaceMeta.get("description"));
315+
316+
return marketplaceApplicationInfoView;
317+
308318
});
309319

310320
});

‎server/api-service/lowcoder-server/src/main/resources/application-lowcoder.yml

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ common:
4444
block-hound-enable: false
4545
js-executor:
4646
host: http://127.0.0.1:6060
47+
marketplace:
48+
private-mode: false
4749

4850
material:
4951
mongodb-grid-fs:

‎server/api-service/lowcoder-server/src/main/resources/selfhost/ce/application.yml

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ common:
5353
max-query-timeout: ${LOWCODER_MAX_QUERY_TIMEOUT:120}
5454
workspace:
5555
mode: ${LOWCODER_WORKSPACE_MODE:SAAS}
56+
marketplace:
57+
private-mode: ${MARKETPLACE_PRIVATE_MODE:true}
5658

5759
material:
5860
mongodb-grid-fs:

0 commit comments

Comments
 (0)