Skip to content

Commit

Permalink
Fix org list by email
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonpoo authored and ludomikula committed Oct 23, 2024
1 parent 49a4a61 commit 1ff153e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public interface UserService {
Mono<Map<String, User>> getByIds(Collection<String> ids);

Mono<User> findBySourceAndId(String connectionSource, String connectionSourceUuid);
Mono<User> findByEmailDeep(String email);

Mono<Boolean> saveProfilePhoto(Part filePart, User t2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public Mono<User> findByName(String rawUuid) {
return repository.findByName(rawUuid);
}

@Override
public Mono<User> findByEmailDeep(String email) {
if(StringUtils.isEmpty(email)) return Mono.empty();
return repository.findByEmailOrConnections_Email(email, email).next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.lowcoder.domain.organization.service.OrganizationService;
import org.lowcoder.domain.plugin.DatasourceMetaInfo;
import org.lowcoder.domain.plugin.service.DatasourceMetaInfoService;
import org.lowcoder.domain.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.codec.multipart.Part;
import org.springframework.web.bind.annotation.*;
Expand All @@ -41,10 +42,12 @@ public class OrganizationController implements OrganizationEndpoints
private OrgMemberService orgMemberService;
@Autowired
private OrganizationService organizationService;
@Autowired
private UserService userService;

@Override
public Mono<ResponseView<List<OrgView>>> getOrganizationByUser(@PathVariable String userId) {
return orgMemberService.getAllActiveOrgs(userId)
public Mono<ResponseView<List<OrgView>>> getOrganizationByUser(@PathVariable String email) {
return userService.findByEmailDeep(email).flux().flatMap(user -> orgMemberService.getAllActiveOrgs(user.getId()))
.flatMap(orgMember -> organizationService.getById(orgMember.getOrgId()))
.map(OrgView::new)
.collectList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public interface OrganizationEndpoints
summary = "Get a list of specified user's organization",
description = "Get a list of specified user's organization"
)
@GetMapping("/byuser/{userId}")
public Mono<ResponseView<List<OrgView>>> getOrganizationByUser(@PathVariable String userId);
@GetMapping("/byuser/{email}")
public Mono<ResponseView<List<OrgView>>> getOrganizationByUser(@PathVariable String email);

@Operation(
tags = TAG_ORGANIZATION_MANAGEMENT,
Expand Down

0 comments on commit 1ff153e

Please sign in to comment.