diff --git a/src/main/java/Gotcha/domain/notification/dto/NotificationSortType.java b/src/main/java/Gotcha/domain/notification/dto/NotificationSortType.java index d305ff56..532172f3 100644 --- a/src/main/java/Gotcha/domain/notification/dto/NotificationSortType.java +++ b/src/main/java/Gotcha/domain/notification/dto/NotificationSortType.java @@ -1,25 +1,18 @@ package Gotcha.domain.notification.dto; -import lombok.Getter; import org.springframework.data.domain.Sort; -import com.querydsl.core.types.OrderSpecifier; - -import static Gotcha.domain.notification.entity.QNotification.notification; public enum NotificationSortType { - DATE_DESC("createdAt", Sort.Direction.DESC, notification.createdAt.desc()), - DATE_ASC("createdAt", Sort.Direction.ASC, notification.createdAt.asc()); + DATE_DESC("createdAt", Sort.Direction.DESC), + DATE_ASC("createdAt", Sort.Direction.ASC); - private String type; - private Sort.Direction direction; + private final String type; + private final Sort.Direction direction; - @Getter - private OrderSpecifier order; - NotificationSortType(String type, Sort.Direction direction, OrderSpecifier order){ + NotificationSortType(String type, Sort.Direction direction){ this.type = type; this.direction = direction; - this.order = order; } public Sort getSort(){ diff --git a/src/main/java/Gotcha/domain/notification/service/NotificationService.java b/src/main/java/Gotcha/domain/notification/service/NotificationService.java index e805fa78..0cf7675a 100644 --- a/src/main/java/Gotcha/domain/notification/service/NotificationService.java +++ b/src/main/java/Gotcha/domain/notification/service/NotificationService.java @@ -27,7 +27,7 @@ public class NotificationService { @Transactional(readOnly = true) public Page getNotifications(String keyword, Integer page, NotificationSortType sort){ - Pageable pageable = PageRequest.of(page, NOTIS_PER_PAGE); + Pageable pageable = PageRequest.of(page, NOTIS_PER_PAGE, sort.getSort()); Page notifications = notificationRepository.findByTitleContainingIgnoreCase(keyword, pageable);