Skip to content

Commit

Permalink
Merge pull request #101 from SOPT-SOPHY/feat/#96-add-isapply
Browse files Browse the repository at this point in the history
fix: 비회원일 때 북토크 상세조회 가능하도록 수정
  • Loading branch information
onpyeong authored Oct 13, 2023
2 parents 713952b + b9014e3 commit dbf7be5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ public class BooktalkController {
@GetMapping("/search/{booktalkId}/detail")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "북토크 상세 조회")
@SecurityRequirement(name = "JWT Auth")
public ApiResponseDto<BooktalkDetailResponseDto> getBooktalkDetail(
@Parameter(hidden = true) @AuthenticationPrincipal User user,
@Parameter(example = "1") @PathVariable("booktalkId") Long booktalkId) {
return ApiResponseDto.success(SuccessStatus.GET_BOOKTALK_DETAIL_SUCCESS,
booktalkService.getBooktalkDetail(user.getUsername(), booktalkId));
booktalkService.getBooktalkDetail(user == null ? "" : user.getUsername(), booktalkId));
}

@GetMapping("/search")
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/sophy/sophy/service/BooktalkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ public BooktalkDeleteResponseDto deleteBooktalk(

// 북토크 상세 조회
public BooktalkDetailResponseDto getBooktalkDetail(String email, Long booktalkId) {
Member member = memberRepository.getMemberByEmail(email);
Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkId);
Boolean isApply = member.getUserBookTalkList()
.stream().anyMatch(memberBooktalk -> memberBooktalk.getBooktalk().equals(booktalk));
boolean isApply = false;
if (!email.isEmpty()) {
Member member = memberRepository.getMemberByEmail(email);
isApply = member.getUserBookTalkList()
.stream().anyMatch(memberBooktalk -> memberBooktalk.getBooktalk().equals(booktalk));
}
return BooktalkDetailResponseDto.of(booktalk, isApply);
}

Expand Down

0 comments on commit dbf7be5

Please sign in to comment.