Skip to content

Commit

Permalink
feat: implement get member related api
Browse files Browse the repository at this point in the history
  • Loading branch information
gmkim20713 committed Nov 22, 2024
1 parent 412eae1 commit c2c2c9d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 12 additions & 3 deletions user-service/src/main/java/kr/mafoo/user/api/MemberApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.mafoo.user.annotation.RequestMemberId;
import kr.mafoo.user.controller.dto.response.MemberDetailResponse;
import kr.mafoo.user.controller.dto.response.MemberResponse;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -17,16 +19,23 @@
@Validated
@RequestMapping("/v1/members")
public interface MemberApi {
@Operation(summary = "사용자 검색", description = "키워드로 사용자를 검색합니다. (이름으로 검색)")
@Operation(summary = "공유 앨범 대상 사용자 검색", description = "키워드로 사용자를 검색합니다. (이름으로 검색)")
@GetMapping
Flux<MemberResponse> getMemberListByName(
Flux<MemberDetailResponse> getMemberListByNameForSharedAlbum(
@RequestMemberId
@Parameter(hidden = true)
String requesterId,

@Parameter(description = "검색어", example = "사람")
@RequestParam
String keyword
String keyword,

@Parameter(description = "앨범 ID", example = "test_album_id")
@RequestParam
String albumId,

// Authorization Header를 받아올 목적
ServerHttpRequest serverHttpRequest
);

@Operation(summary = "사용자 단건 조회", description = "사용자 단건 정보를 조회합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package kr.mafoo.user.controller;

import kr.mafoo.user.api.MemberApi;
import kr.mafoo.user.controller.dto.response.MemberDetailResponse;
import kr.mafoo.user.controller.dto.response.MemberResponse;
import kr.mafoo.user.service.MemberService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand All @@ -14,12 +16,16 @@ public class MemberController implements MemberApi {
private final MemberService memberService;

@Override
public Flux<MemberResponse> getMemberListByName(
public Flux<MemberDetailResponse> getMemberListByNameForSharedAlbum(
String requesterId,
String keyword
String keyword,
String albumId,
ServerHttpRequest serverHttpRequest
) {
return memberService.getMemberByKeyword(keyword)
.map(MemberResponse::fromEntity);
String authorizationToken = serverHttpRequest.getHeaders().getFirst("Authorization");

return memberService.getMemberByKeywordForSharedAlbum(keyword, albumId, authorizationToken)
.map(MemberDetailResponse::fromDto);
}

@Override
Expand Down

0 comments on commit c2c2c9d

Please sign in to comment.