diff --git a/src/main/java/org/sophy/sophy/controller/BooktalkController.java b/src/main/java/org/sophy/sophy/controller/BooktalkController.java index 31273a0..72d7bf5 100644 --- a/src/main/java/org/sophy/sophy/controller/BooktalkController.java +++ b/src/main/java/org/sophy/sophy/controller/BooktalkController.java @@ -38,11 +38,12 @@ public class BooktalkController { @GetMapping("/search/{booktalkId}/detail") @ResponseStatus(HttpStatus.OK) @Operation(summary = "북토크 상세 조회") + @SecurityRequirement(name = "JWT Auth") public ApiResponseDto 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") diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index 88bfec4..4fd3cbf 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -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); }