diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/admissions/database/AdmissionsPostType.kt b/src/main/kotlin/com/wafflestudio/csereal/core/admissions/database/AdmissionsPostType.kt deleted file mode 100644 index be0adf3f..00000000 --- a/src/main/kotlin/com/wafflestudio/csereal/core/admissions/database/AdmissionsPostType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.wafflestudio.csereal.core.admissions.database - -enum class AdmissionsPostType { - GRADUATE, UNDERGRADUATE_EARLY_ADMISSION, UNDERGRADUATE_REGULAR_ADMISSION, -} diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsMainType.kt b/src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsMainType.kt new file mode 100644 index 00000000..7329ee64 --- /dev/null +++ b/src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsMainType.kt @@ -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입니다.") + } + } +} diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsPostType.kt b/src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsPostType.kt new file mode 100644 index 00000000..baf1c6ab --- /dev/null +++ b/src/main/kotlin/com/wafflestudio/csereal/core/admissions/type/AdmissionsPostType.kt @@ -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이 주어졌습니다.") + } + } +}