Skip to content

Commit

Permalink
🐛 홈 화면 랜덤 명언 조회 user_id 없으면 전체 목록 조회하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyesooo committed Dec 10, 2023
1 parent 1be19f3 commit 807aa00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ public class SearchController {
)
public ApiRes<Page<QuoteResource>> 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)));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Page<QuoteDto> 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("이미 좋아요 등록된 명언입니다.");
Expand Down

0 comments on commit 807aa00

Please sign in to comment.