diff --git a/src/main/java/com/hallym/festival/domain/notice/repository/NoticeRepository.java b/src/main/java/com/hallym/festival/domain/notice/repository/NoticeRepository.java index a3d7d9f..7ce27b2 100644 --- a/src/main/java/com/hallym/festival/domain/notice/repository/NoticeRepository.java +++ b/src/main/java/com/hallym/festival/domain/notice/repository/NoticeRepository.java @@ -7,8 +7,8 @@ import java.util.List; public interface NoticeRepository extends JpaRepository { - List findAllByActive(Boolean active); - List findByTitleContainingAndActive(String keyword, Boolean active); + List findAllByActiveOrderByRegDateDesc(Boolean active); + List findByTitleContainingAndActiveOrderByRegDateDesc(String keyword, Boolean active); } diff --git a/src/main/java/com/hallym/festival/domain/notice/service/NoticeService.java b/src/main/java/com/hallym/festival/domain/notice/service/NoticeService.java index ef6da33..f04e322 100644 --- a/src/main/java/com/hallym/festival/domain/notice/service/NoticeService.java +++ b/src/main/java/com/hallym/festival/domain/notice/service/NoticeService.java @@ -29,7 +29,7 @@ public NoticeDto create(NoticeDto noticeDto) { } public List getNoticeList() { - List noticeList = noticeRepository.findAllByActive(Boolean.TRUE); + List noticeList = noticeRepository.findAllByActiveOrderByRegDateDesc(Boolean.TRUE); return noticeList.stream() .map(notice -> notice.toDto()) .collect(Collectors.toList()); @@ -59,7 +59,7 @@ public NoticeDto update(Long id, NoticeDto noticeDto) { @Transactional public List search(String keyword) { - List noticeList = noticeRepository.findByTitleContainingAndActive(keyword, Boolean.TRUE); + List noticeList = noticeRepository.findByTitleContainingAndActiveOrderByRegDateDesc(keyword, Boolean.TRUE); List noticeDtoList = new ArrayList<>(); if(noticeList.isEmpty()) return noticeDtoList; for (Notice notice : noticeList) {