From 807aa000eb5cf45d2bcb33a2406965c4347a909a Mon Sep 17 00:00:00 2001 From: Hyesooo Date: Sun, 10 Dec 2023 19:08:12 +0900 Subject: [PATCH] =?UTF-8?q?:bug:=20=ED=99=88=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EB=9E=9C=EB=8D=A4=20=EB=AA=85=EC=96=B8=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?user=5Fid=20=EC=97=86=EC=9C=BC=EB=A9=B4=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=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 --- .../quoteBakery/app/controller/SearchController.java | 5 ++--- .../app/service/implementation/QuoteServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/pingpong/quoteBakery/app/controller/SearchController.java b/src/main/java/com/pingpong/quoteBakery/app/controller/SearchController.java index 16f9b9e..e682aef 100644 --- a/src/main/java/com/pingpong/quoteBakery/app/controller/SearchController.java +++ b/src/main/java/com/pingpong/quoteBakery/app/controller/SearchController.java @@ -43,11 +43,10 @@ public class SearchController { ) public ApiRes> searchQuotes(@RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody QuoteSearchResource searchResource){ String uid = tokenService.getCurrentTokenInfo().getUid(); - if(uid == null) throw new BusinessInvalidValueException("명언 탐색을 위해 로그인해주세요."); + Long userId = uid == null || uid.isBlank() ? null : userService.findByUid(uid).getId(); - UserDto userDto = userService.findByUid(uid); return ApiRes.createSuccess(quoteService.searchQuotePages(quoteConverter.convertToGeneric(searchResource, QuoteMultiSearchDto.class), searchResource.getPageInfo()) - .map(quote -> quoteConverter.convertDtoToRandomResource(quote, userDto.getId()))); + .map(quote -> quoteConverter.convertDtoToRandomResource(quote, userId))); } } diff --git a/src/main/java/com/pingpong/quoteBakery/app/service/implementation/QuoteServiceImpl.java b/src/main/java/com/pingpong/quoteBakery/app/service/implementation/QuoteServiceImpl.java index 6e4106e..4fa0175 100644 --- a/src/main/java/com/pingpong/quoteBakery/app/service/implementation/QuoteServiceImpl.java +++ b/src/main/java/com/pingpong/quoteBakery/app/service/implementation/QuoteServiceImpl.java @@ -82,7 +82,7 @@ public Page searchQuotePages(QuoteMultiSearchDto searchDto, Pageable p public Long saveLike(LikeDto likeDto) { User user = userService.findById(likeDto.getUserId()); Quote quote = quoteRepository.findById(likeDto.getQuoteId()) - .orElseThrow(() -> new BusinessInvalidValueException("해당 ID에 대한 정보가 없습니다.")); + .orElseThrow(() -> new BusinessInvalidValueException("해당 명언에 대한 정보가 없습니다.")); boolean existYn = likeRepository.existsByUserAndQuote(user, quote); if (existYn) throw new BusinessInvalidValueException("이미 좋아요 등록된 명언입니다.");