Skip to content

Commit

Permalink
feat: 반환된 기대평 list를 역순으로 정렬
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeokson committed Aug 17, 2024
1 parent 97f8042 commit 5f731c2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

@Service
Expand All @@ -29,8 +30,9 @@ public class CommentService {
public CommentsResponseDto getComments(Integer userId, Integer cursor) {

PageRequest pageRequest = PageRequest.of(0, SCROLL_SIZE + 1);
Page<Comment> page = commentRepository.findAllByIdLessThanOrderById(cursor, pageRequest);
Page<Comment> page = commentRepository.findAllByIdLessThanOrderByIdDesc(cursor, pageRequest);
List<Comment> comments = page.getContent();
Collections.reverse(comments);

ScrollPaginationUtil<Comment> commentCursor = ScrollPaginationUtil.of(comments, SCROLL_SIZE);
return CommentsResponseDto.of(commentCursor, userId);
Expand Down

0 comments on commit 5f731c2

Please sign in to comment.