-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from olmangjolmang/OMJM-104-post_sort_enhance
✨ Feat: post 최신순, 오래된순, 스크랩순 정렬 기능
- Loading branch information
Showing
3 changed files
with
37 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/ticle/server/post/domain/type/PostSort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.ticle.server.post.domain.type; | ||
|
||
import com.ticle.server.opinion.domain.type.Order; | ||
import org.springframework.data.domain.Sort; | ||
|
||
public enum PostSort { | ||
LATEST, // 최신순 | ||
OLDEST, // 오래된순 | ||
SCRAPPED; // 스크랩순 | ||
|
||
public static Sort getOrder(PostSort orderBy) { | ||
return switch (orderBy) { | ||
case LATEST -> Sort.by(Sort.Direction.DESC, "createdDate"); | ||
case OLDEST -> Sort.by(Sort.Direction.ASC, "createdDate"); | ||
case SCRAPPED -> Sort.by(Sort.Direction.DESC, "scrapCount"); | ||
|
||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters