Skip to content

Commit bf9870d

Browse files
Thomasrludomikula
Thomasr
authored andcommitted
Get Organization List by User Id
1 parent f588333 commit bf9870d

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
110110
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, GROUP_URL + "/list"), // application view
111111
ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, QUERY_URL + "/execute"), // application view
112112
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, ORGANIZATION_URL + "/*/datasourceTypes"), // datasource types
113+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, ORGANIZATION_URL + "/byuser/*"),
113114
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, DATASOURCE_URL + "/jsDatasourcePlugins"),
114115

115116
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, GITHUB_STAR),
@@ -142,6 +143,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
142143
ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, NewUrl.QUERY_URL + "/execute"),
143144
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.MATERIAL_URL + "/**"),
144145
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.ORGANIZATION_URL + "/*/datasourceTypes"), // datasource types
146+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.ORGANIZATION_URL + "/byuser/*"),
145147
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.DATASOURCE_URL + "/jsDatasourcePlugins"),
146148
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, "/api/docs/**")
147149
)

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/usermanagement/OrganizationController.java

+15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.lowcoder.api.util.GidService;
1414
import org.lowcoder.domain.organization.model.Organization;
1515
import org.lowcoder.domain.organization.model.Organization.OrganizationCommonSettings;
16+
import org.lowcoder.domain.organization.service.OrgMemberService;
17+
import org.lowcoder.domain.organization.service.OrganizationService;
1618
import org.lowcoder.domain.plugin.DatasourceMetaInfo;
1719
import org.lowcoder.domain.plugin.service.DatasourceMetaInfoService;
1820
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +37,19 @@ public class OrganizationController implements OrganizationEndpoints
3537
private BusinessEventPublisher businessEventPublisher;
3638
@Autowired
3739
private GidService gidService;
40+
@Autowired
41+
private OrgMemberService orgMemberService;
42+
@Autowired
43+
private OrganizationService organizationService;
44+
45+
@Override
46+
public Mono<ResponseView<List<OrgView>>> getOrganizationByUser(@PathVariable String userId) {
47+
return orgMemberService.getAllActiveOrgs(userId)
48+
.flatMap(orgMember -> organizationService.getById(orgMember.getOrgId()))
49+
.map(OrgView::new)
50+
.collectList()
51+
.map(ResponseView::success);
52+
}
3853

3954
@Override
4055
public Mono<ResponseView<OrgView>> create(@Valid @RequestBody Organization organization) {

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/usermanagement/OrganizationEndpoints.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,21 @@ public interface OrganizationEndpoints
3939

4040
@Operation(
4141
tags = TAG_ORGANIZATION_MANAGEMENT,
42-
operationId = "createOrganization",
43-
summary = "Create a new Organization",
44-
description = "Create a new Organization (Workspace) within the Lowcoder platform as a encapsulated space for Applications, Users and Resources."
42+
operationId = "getOrganizationByUser",
43+
summary = "Get a list of specified user's organization",
44+
description = "Get a list of specified user's organization"
4545
)
46-
@PostMapping
47-
public Mono<ResponseView<OrgView>> create(@Valid @RequestBody Organization organization);
46+
@GetMapping("/byuser/{userId}")
47+
public Mono<ResponseView<List<OrgView>>> getOrganizationByUser(@PathVariable String userId);
48+
49+
@Operation(
50+
tags = TAG_ORGANIZATION_MANAGEMENT,
51+
operationId = "createOrganization",
52+
summary = "Create a new Organization",
53+
description = "Create a new Organization (Workspace) within the Lowcoder platform as a encapsulated space for Applications, Users and Resources."
54+
)
55+
@PostMapping
56+
public Mono<ResponseView<OrgView>> create(@Valid @RequestBody Organization organization);
4857

4958
@Operation(
5059
tags = TAG_ORGANIZATION_MANAGEMENT,

0 commit comments

Comments
 (0)