Skip to content

Commit

Permalink
Fix : 공지사항 응답순서를 최신순으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
koomin1227 committed Oct 19, 2024
1 parent b886056 commit 40f1bf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
public interface AnnouncementRepository extends JpaRepository<Announcement, Long> {
@Query("SELECT a FROM Announcement a WHERE a.id < :cursor ORDER BY a.id DESC LIMIT :size")
List<Announcement> findAllAnnouncement(@Param("cursor") Long cursor, @Param("size") int size);

@Query("SELECT a FROM Announcement a ORDER BY a.id DESC LIMIT :size")
List<Announcement> findAllRecentAnnouncement(@Param("size") int size);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ public List<EventResponse> getEvents() {
}

public List<AnnouncementResponse> getAnnouncements(Long cursor) {
List<Announcement> announcements = announcementRepository.findAllAnnouncement(cursor, PAGE_SIZE);
List<Announcement> announcements;
if (cursor == 0) {
announcements = announcementRepository.findAllRecentAnnouncement(PAGE_SIZE);
} else {
announcements = announcementRepository.findAllAnnouncement(cursor, PAGE_SIZE);
}

return announcements.stream()
.map(announcement -> AnnouncementResponse.builder()
Expand Down

0 comments on commit 40f1bf1

Please sign in to comment.