From b9014e31ebb56813c2915ff4fdd38600d1f52bab Mon Sep 17 00:00:00 2001 From: onpyeong Date: Fri, 13 Oct 2023 13:29:11 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B9=84=ED=9A=8C=EC=9B=90=EC=9D=BC=20?= =?UTF-8?q?=EB=95=8C=20=EB=B6=81=ED=86=A0=ED=81=AC=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/sophy/sophy/controller/BooktalkController.java | 3 ++- .../java/org/sophy/sophy/service/BooktalkService.java | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) 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); }