-
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.
Feat: Move type to type dir, and add main type enum.
- Loading branch information
Showing
3 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
5 changes: 0 additions & 5 deletions
5
src/main/kotlin/com/wafflestudio/csereal/core/admissions/database/AdmissionsPostType.kt
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsMainType.kt
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,21 @@ | ||
package com.wafflestudio.csereal.core.admissions.type | ||
|
||
import com.wafflestudio.csereal.common.CserealException | ||
|
||
enum class AdmissionsMainType { | ||
UNDERGRADUATE, | ||
GRADUATE, | ||
INTERNATIONAL; | ||
|
||
fun toJsonValue() = this.name.lowercase() | ||
|
||
companion object { | ||
fun fromJsonValue(field: String) = try { | ||
field | ||
.uppercase() | ||
.let { AdmissionsMainType.valueOf(it) } | ||
} catch (e: IllegalArgumentException) { | ||
throw CserealException.Csereal400("존재하지 않는 Admission Main Type입니다.") | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsPostType.kt
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,28 @@ | ||
package com.wafflestudio.csereal.core.admissions.type | ||
|
||
import com.wafflestudio.csereal.common.CserealException | ||
|
||
enum class AdmissionsPostType { | ||
// For graduate, undergraduate | ||
EARLY_ADMISSION, | ||
REGULAR_ADMISSION, | ||
|
||
// For international | ||
UNDERGRADUATE, | ||
GRADUATE, | ||
EXCHANGE_VISITING, | ||
SCHOLARSHIPS; | ||
|
||
fun toJsonValue() = this.name.lowercase() | ||
|
||
companion object { | ||
fun fromJsonValue(field: String) = | ||
try { | ||
field.replace('_', '-') | ||
.uppercase() | ||
.let { AdmissionsPostType.valueOf(it) } | ||
} catch (e: IllegalArgumentException) { | ||
throw CserealException.Csereal400("잘못된 Admission Post Type이 주어졌습니다.") | ||
} | ||
} | ||
} |