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("이미 좋아요 등록된 명언입니다.");