-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
52 additions
and
2 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
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
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,33 @@ | ||
package com.wafflestudio.snu4t.common.enum | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue | ||
import com.wafflestudio.snu4t.common.extension.asc | ||
import com.wafflestudio.snu4t.common.extension.desc | ||
import com.wafflestudio.snu4t.lectures.data.EvInfo | ||
import com.wafflestudio.snu4t.lectures.data.Lecture | ||
import org.springframework.data.domain.Sort | ||
import org.springframework.data.mapping.div | ||
|
||
enum class SortCriteria( | ||
val value: Int, | ||
@JsonValue | ||
val fullName: String | ||
) { | ||
ID(1, "기본값"), | ||
RATING_DESC(2, "평점 높은 순"), | ||
RATING_ASC(3, "평점 낮은 순"), | ||
COUNT_DESC(4, "강의평 많은 순"), | ||
COUNT_ASC(5, "강의평 적은 순"); | ||
|
||
companion object { | ||
private val nameMap = values().associateBy { it.fullName } | ||
fun getOfName(sortCriteriaName: String?): SortCriteria? = nameMap[sortCriteriaName] | ||
fun getSort(sortCriteria: SortCriteria?): Sort = when (sortCriteria) { | ||
RATING_DESC -> (Lecture::evInfo / EvInfo::avgRating).desc() | ||
RATING_ASC -> (Lecture::evInfo / EvInfo::avgRating).asc() | ||
COUNT_DESC -> (Lecture::evInfo / EvInfo::count).desc() | ||
COUNT_ASC -> (Lecture::evInfo / EvInfo::count).asc() | ||
else -> Sort.unsorted() | ||
} | ||
} | ||
} |
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,7 @@ | ||
package com.wafflestudio.snu4t.lectures.data | ||
|
||
data class EvInfo( | ||
val evId: String? = null, | ||
val avgRating: Double?, | ||
val count: Int?, | ||
) |
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
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
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
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