Skip to content

Commit

Permalink
Merge pull request #191 from PawWithU/feat/190-intermediary-info-api
Browse files Browse the repository at this point in the history
[Feature] 모집자 프로필 - 기본 정보 조회 API 구현
  • Loading branch information
hojeong2747 authored May 11, 2024
2 parents 36cbfab + 4f940a1 commit c84343e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,44 @@ public ResponseEntity<List<IntermediaryGetPostsResponse>> volunteerGetIntermedia
return ResponseEntity.ok(response);
}

@Operation(summary = "중개자 - 중개 프로필 - 이동봉사 공고 목록 조회", description = "중개 프로필에서 이동봉사 공고 목록을 조회합니다.",
@Operation(summary = "모집자 - 중개 프로필 - 이동봉사 공고 목록 조회", description = "중개 프로필에서 이동봉사 공고 목록을 조회합니다.",
security = { @SecurityRequirement(name = "bearer-key") },
responses = {@ApiResponse(responseCode = "200", description = "이동봉사 공고 목록 조회 성공")
, @ApiResponse(responseCode = "400"
, description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다."
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping(value = "/intermediaries/posts")
@GetMapping(value = "/intermediaries/my/posts")
public ResponseEntity<List<IntermediaryGetPostsResponse>> intermediaryGetIntermediaryPosts(@AuthenticationPrincipal UserDetails loginUser,
@RequestParam(required = false) String orderCondition,
Pageable pageable) {
List<IntermediaryGetPostsResponse> response = intermediaryService.intermediaryGetIntermediaryPosts(loginUser.getUsername(), orderCondition, pageable);
return ResponseEntity.ok(response);
}

@Operation(summary = "중개 프로필 - 기본 정보 조회", description = "중개 프로필에서 기본 정보를 조회합니다.",
@Operation(summary = "이동봉사자 - 중개 프로필 - 기본 정보 조회", description = "중개 프로필에서 기본 정보를 조회합니다.",
security = { @SecurityRequirement(name = "bearer-key") },
responses = {@ApiResponse(responseCode = "200", description = "중개 프로필 기본 정보 조회 성공")
, @ApiResponse(responseCode = "400"
, description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다."
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping("/volunteers/intermediaries/{intermediaryId}")
public ResponseEntity<IntermediaryGetInfoResponse> getIntermediaryInfo(@PathVariable Long intermediaryId) {
IntermediaryGetInfoResponse response = intermediaryService.getIntermediaryInfo(intermediaryId);
public ResponseEntity<IntermediaryGetInfoResponse> volunteerGetIntermediaryInfo(@PathVariable Long intermediaryId) {
IntermediaryGetInfoResponse response = intermediaryService.volunteerGetIntermediaryInfo(intermediaryId);
return ResponseEntity.ok(response);
}

@Operation(summary = "모집자 - 중개 프로필 - 기본 정보 조회", description = "중개 프로필에서 기본 정보를 조회합니다.",
security = { @SecurityRequirement(name = "bearer-key") },
responses = {@ApiResponse(responseCode = "200", description = "중개 프로필 기본 정보 조회 성공")
, @ApiResponse(responseCode = "400"
, description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다."
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping("/intermediaries/my/info")
public ResponseEntity<IntermediaryGetInfoResponse> intermediaryGetIntermediaryInfo(@AuthenticationPrincipal UserDetails loginUser) {
IntermediaryGetInfoResponse response = intermediaryService.intermediaryGetIntermediaryInfo(loginUser.getUsername());
return ResponseEntity.ok(response);
}

Expand All @@ -92,7 +105,7 @@ public ResponseEntity<List<IntermediaryGetReviewsResponse>> volunteerGetIntermed
, description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다."
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping("/intermediaries/reviews")
@GetMapping("/intermediaries/my/reviews")
public ResponseEntity<List<IntermediaryGetReviewsResponse>> intermediaryGetIntermediaryReviews(@AuthenticationPrincipal UserDetails loginUser, Pageable pageable) {
List<IntermediaryGetReviewsResponse> response = intermediaryService.intermediaryGetIntermediaryReviews(loginUser.getUsername(), pageable);
return ResponseEntity.ok(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ public List<IntermediaryGetPostsResponse> volunteerGetIntermediaryPosts(Long int
}

@Transactional(readOnly = true)
public IntermediaryGetInfoResponse getIntermediaryInfo(Long intermediaryId) {
public IntermediaryGetInfoResponse volunteerGetIntermediaryInfo(Long intermediaryId) {
Intermediary intermediary = intermediaryRepository.findById(intermediaryId).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
IntermediaryGetInfoResponse intermediaryInfo = IntermediaryGetInfoResponse.from(intermediary);
return intermediaryInfo;
}

@Transactional(readOnly = true)
public IntermediaryGetInfoResponse intermediaryGetIntermediaryInfo(String username) {
Intermediary intermediary = intermediaryRepository.findByEmail(username).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
IntermediaryGetInfoResponse intermediaryInfo = IntermediaryGetInfoResponse.from(intermediary);
return intermediaryInfo;
}

@Transactional(readOnly = true)
public List<IntermediaryGetReviewsResponse> volunteerGetIntermediaryReviews(Long intermediaryId, Pageable pageable) {
// 이동봉사 중개
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void setUp() {
//when
given(intermediaryService.intermediaryGetIntermediaryPosts(anyString(), anyString(), any())).willReturn(response);
ResultActions result = mockMvc.perform(
get("/intermediaries/posts")
get("/intermediaries/my/posts")
.param("orderCondition", "최신순")
);

Expand All @@ -117,16 +117,35 @@ void setUp() {
"이동봉사 중개 이름", "안녕하세요. 한 줄 소개 입니다.", "https://connectdog.site", "인스타그램: @hoxjeong", "안내 사항입니다.");

// when
given(intermediaryService.getIntermediaryInfo(anyLong())).willReturn(response);
given(intermediaryService.volunteerGetIntermediaryInfo(anyLong())).willReturn(response);
ResultActions result = mockMvc.perform(
get("/volunteers/intermediaries/{intermediaryId}", intermediaryId)
);

// then
result.andExpect(status().isOk());
verify(intermediaryService, times(1)).getIntermediaryInfo(anyLong());
verify(intermediaryService, times(1)).volunteerGetIntermediaryInfo(anyLong());
}

@Test
void 모집자_중개_프로필_기본_정보_조회() throws Exception {
// given
Long intermediaryId = 1L;
IntermediaryGetInfoResponse response = new IntermediaryGetInfoResponse("profileImage",
"이동봉사 중개 이름", "안녕하세요. 한 줄 소개 입니다.", "https://connectdog.site", "인스타그램: @hoxjeong", "안내 사항입니다.");

// when
given(intermediaryService.intermediaryGetIntermediaryInfo(anyString())).willReturn(response);
ResultActions result = mockMvc.perform(
get("/intermediaries/my/info")
);

// then
result.andExpect(status().isOk());
verify(intermediaryService, times(1)).intermediaryGetIntermediaryInfo(anyString());
}


@Test
void 이동봉사자_중개_프로필_후기_조회() throws Exception {
// given
Expand Down Expand Up @@ -187,7 +206,7 @@ void setUp() {
// when
given(intermediaryService.intermediaryGetIntermediaryReviews(anyString(), any())).willReturn(response);
ResultActions result = mockMvc.perform(
get("/intermediaries/reviews", intermediaryId)
get("/intermediaries/my/reviews", intermediaryId)
.param("page", "0")
.param("size", "2")
);
Expand Down

0 comments on commit c84343e

Please sign in to comment.