diff --git a/user-service/src/main/java/kr/mafoo/user/controller/dto/response/MemberDetailResponse.java b/user-service/src/main/java/kr/mafoo/user/controller/dto/response/MemberDetailResponse.java new file mode 100644 index 0000000..a3dd538 --- /dev/null +++ b/user-service/src/main/java/kr/mafoo/user/controller/dto/response/MemberDetailResponse.java @@ -0,0 +1,42 @@ +package kr.mafoo.user.controller.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import kr.mafoo.user.service.dto.MemberDetailDto; + +@Schema(description = "사용자의 정보 응답") +public record MemberDetailResponse( + @Schema(description = "사용자 ID", example = "test") + String memberId, + + @Schema(description = "사용자 이름", example = "송영민") + String name, + + @Schema(description = "프로필 이미지 URL", example = "https://mafoo.kr/profile.jpg") + String profileImageUrl, + + @Schema(description = "식별 번호", example = "0000") + String serialNumber, + + @Schema(description = "공유 사용자 ID", example = "test_shared_member_id") + String sharedMemberId, + + @Schema(description = "공유 상태", example = "PENDING") + String shareStatus, + + @Schema(description = "권한 단계", example = "FULL_ACCESS") + String permissionLevel +) { + public static MemberDetailResponse fromDto( + MemberDetailDto dto + ) { + return new MemberDetailResponse( + dto.memberId(), + dto.name(), + dto.profileImageUrl(), + dto.serialNumber(), + dto.sharedMemberId(), + dto.shareStatus(), + dto.permissionLevel() + ); + } +} diff --git a/user-service/src/main/java/kr/mafoo/user/service/MemberService.java b/user-service/src/main/java/kr/mafoo/user/service/MemberService.java index 1b30a5e..f0afa27 100644 --- a/user-service/src/main/java/kr/mafoo/user/service/MemberService.java +++ b/user-service/src/main/java/kr/mafoo/user/service/MemberService.java @@ -4,6 +4,7 @@ import kr.mafoo.user.exception.MemberNotFoundException; import kr.mafoo.user.repository.MemberRepository; import kr.mafoo.user.repository.SocialMemberRepository; +import kr.mafoo.user.service.dto.MemberDetailDto; import kr.mafoo.user.util.IdGenerator; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,6 +20,7 @@ public class MemberService { private final MemberRepository memberRepository; private final SocialMemberRepository socialMemberRepository; private final SlackService slackService; + private final SharedMemberService sharedMemberService; @Transactional public Mono quitMemberByMemberId(String memberId) { @@ -27,10 +29,13 @@ public Mono quitMemberByMemberId(String memberId) { .then(memberRepository.deleteMemberById(memberId)); } - public Flux getMemberByKeyword(String keyword) { + public Flux getMemberByKeywordForSharedAlbum(String keyword, String albumId, String token) { return memberRepository .findAllByNameContaining(keyword) - .switchIfEmpty(Mono.error(new MemberNotFoundException())); + .switchIfEmpty(Mono.error(new MemberNotFoundException())) + .concatMap(member -> sharedMemberService.getSharedMemberInfoByAlbumId(albumId, member.getId(), token) + .flatMap(sharedMemberDto -> Mono.just(MemberDetailDto.fromSharedMember(member, sharedMemberDto))) + ); } public Mono getMemberByMemberId(String memberId) { diff --git a/user-service/src/main/java/kr/mafoo/user/service/dto/MemberDetailDto.java b/user-service/src/main/java/kr/mafoo/user/service/dto/MemberDetailDto.java new file mode 100644 index 0000000..4a6983f --- /dev/null +++ b/user-service/src/main/java/kr/mafoo/user/service/dto/MemberDetailDto.java @@ -0,0 +1,28 @@ +package kr.mafoo.user.service.dto; + +import kr.mafoo.user.domain.MemberEntity; + +public record MemberDetailDto( + String memberId, + String name, + String profileImageUrl, + String serialNumber, + String sharedMemberId, + String shareStatus, + String permissionLevel +) { + public static MemberDetailDto fromSharedMember( + MemberEntity memberEntity, + SharedMemberDto sharedMemberDto + ) { + return new MemberDetailDto( + memberEntity.getId(), + memberEntity.getName(), + memberEntity.getProfileImageUrl(), + String.format("%04d", memberEntity.getSerialNumber()), + sharedMemberDto.sharedMemberId(), + sharedMemberDto.shareStatus(), + sharedMemberDto.permissionLevel() + ); + } +}