Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class NotificationService {

@Transactional(readOnly = true)
public Page<NotificationSummaryRes> 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<Notification> notifications = notificationRepository.findByTitleContainingIgnoreCase(keyword, pageable);

Expand Down