Skip to content

Commit

Permalink
Merge pull request #135 from TeamSobokSobok/update/#134-noticeListSort
Browse files Browse the repository at this point in the history
[Update]: 알림 리스트 최신순으로 반환
  • Loading branch information
dev-Crayon authored May 10, 2024
2 parents d254cda + 47c5dd4 commit 5986210
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

@Service
Expand All @@ -47,6 +49,8 @@ public NoticeResponse getList(Long userId) {
User user = UserServiceUtil.findUserById(userRepository, userId);

List<NoticeInfo> noticeList = noticeQueryRepository.getNoticeList(userId);
Comparator<NoticeInfo> compareByCreatedAt = Comparator.comparing(NoticeInfo::createdAt).reversed();
noticeList.sort(compareByCreatedAt);

return NoticeResponse.builder()
.username(user.getUsername())
Expand Down

0 comments on commit 5986210

Please sign in to comment.