-
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.
Browse files
Browse the repository at this point in the history
* feat: CategoryType 추가 * refactor: CategoryType 반영
- Loading branch information
1 parent
ba5e117
commit c00f54d
Showing
13 changed files
with
58 additions
and
18 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
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
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ import com.few.api.web.controller.admin.request.* | |
import com.few.api.web.controller.admin.response.ImageSourceResponse | ||
import com.few.api.web.controller.description.Description | ||
import com.few.api.web.controller.helper.* | ||
import com.few.data.common.code.CategoryType | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Test | ||
|
@@ -88,7 +89,7 @@ class AdminControllerTest : ControllerTestSpec() { | |
val uri = UriComponentsBuilder.newInstance().path("$BASE_URL/workbooks").build().toUriString() | ||
val title = "title" | ||
val mainImageUrl = URL("http://localhost:8080") | ||
val category = "category" | ||
val category = CategoryType.fromCode(0)!!.name | ||
val description = "description" | ||
val request = AddWorkbookRequest(title, mainImageUrl, category, description) | ||
val body = objectMapper.writeValueAsString(request) | ||
|
@@ -135,7 +136,7 @@ class AdminControllerTest : ControllerTestSpec() { | |
"[email protected]", | ||
URL("http://localhost:8080"), | ||
"title", | ||
"category", | ||
CategoryType.fromCode(0)!!.name, | ||
"contentSource", | ||
ProblemDto( | ||
"title", | ||
|
@@ -157,7 +158,7 @@ class AdminControllerTest : ControllerTestSpec() { | |
"[email protected]", | ||
URL("http://localhost:8080"), | ||
"title", | ||
"category", | ||
CategoryType.fromCode(0)!!.name, | ||
"contentSource", | ||
ProblemDetail( | ||
"title", | ||
|
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
29 changes: 29 additions & 0 deletions
29
data/src/main/kotlin/com/few/data/common/code/CategoryType.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,29 @@ | ||
package com.few.data.common.code | ||
|
||
enum class CategoryType(val code: Byte, val displayName: String) { | ||
POLITICS(0, "정치"), | ||
ECONOMY(10, "경제"), | ||
SOCIETY(20, "사회"), | ||
CULTURE(30, "문화"), | ||
LIFE(40, "생활"), | ||
IT(50, "IT"), | ||
SCIENCE(60, "과학"), | ||
ENTERTAINMENTS(70, "엔터테인먼트"), | ||
SPORTS(80, "스포츠"), | ||
GLOBAL(90, "국제"), | ||
ETC(100, "기타"); | ||
|
||
companion object { | ||
fun fromCode(code: Byte): CategoryType? { | ||
return entries.find { it.code == code } | ||
} | ||
|
||
fun convertToCode(displayName: String): Byte { | ||
return entries.find { it.name == displayName }?.code ?: throw IllegalArgumentException("Invalid category name") | ||
} | ||
|
||
fun convertToDisplayName(code: Byte): String { | ||
return entries.find { it.code == code }?.displayName ?: throw IllegalArgumentException("Invalid category code") | ||
} | ||
} | ||
} |