Skip to content

Commit c1386d9

Browse files
authored
Merge pull request DDD-Community#104 from Minsu-Lee/feature/ingredient-register-type-mismatch
[refactor]: FoodCategory 타입명 서버 enum 기준으로 통일
2 parents 16937ef + 7d5ab1a commit c1386d9

10 files changed

Lines changed: 48 additions & 48 deletions

File tree

data/src/main/kotlin/com/anddd/nevera/data/mapper/IngredientMapper.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ private val KST_ZONE_ID = ZoneId.of("Asia/Seoul")
1414

1515
/**
1616
* API 응답 category 값 → FoodCategory 변환
17-
* 매핑 실패 시 [FoodCategory.Other] 반환
17+
* 매핑 실패 시 [FoodCategory.Etc] 반환
1818
*/
1919
internal fun String.toFoodCategory(): FoodCategory = when (this) {
20-
"VEG", "VEGETABLE" -> FoodCategory.Vegetable
20+
"VEG", "VEGETABLE" -> FoodCategory.Veg
2121
"FRUIT" -> FoodCategory.Fruit
22-
"MEATEGGS", "MEAT", "EGG" -> FoodCategory.MeatEgg
23-
"SEA", "SEAFOOD" -> FoodCategory.Seafood
22+
"MEATEGGS", "MEAT", "EGG" -> FoodCategory.MeatEggs
23+
"SEA", "SEAFOOD" -> FoodCategory.Sea
2424
"DAIRY" -> FoodCategory.Dairy
2525
"SAUCE", "SEASONING" -> FoodCategory.Sauce
26-
"DRINK", "BEVERAGE" -> FoodCategory.Beverage
26+
"DRINK", "BEVERAGE" -> FoodCategory.Drink
2727
"CANDRY", "PROCESSED" -> FoodCategory.Processed
28-
"GRAINS" -> FoodCategory.Other // 곡물류 — FoodCategory에 전용 항목 없어 Other로 임시 매핑
29-
else -> FoodCategory.Other
28+
"GRAINS" -> FoodCategory.Etc // 곡물류 — FoodCategory에 전용 항목 없어 Etc로 임시 매핑
29+
else -> FoodCategory.Etc
3030
}
3131

3232
internal fun IngredientResponse.toDomain(): Ingredient = Ingredient(
@@ -67,15 +67,15 @@ internal fun OcrIngredientDto.toDomain(): OcrIngredient = OcrIngredient(
6767
* [FoodCategory] → API 요청 문자열 변환
6868
*/
6969
internal fun FoodCategory.toApiString(): String = when (this) {
70-
FoodCategory.Vegetable -> "VEG"
70+
FoodCategory.Veg -> "VEG"
7171
FoodCategory.Fruit -> "FRUIT"
72-
FoodCategory.MeatEgg -> "MEATEGGS"
73-
FoodCategory.Seafood -> "SEA"
72+
FoodCategory.MeatEggs -> "MEATEGGS"
73+
FoodCategory.Sea -> "SEA"
7474
FoodCategory.Dairy -> "DAIRY"
7575
FoodCategory.Sauce -> "SAUCE"
76-
FoodCategory.Beverage -> "BEVERAGE"
76+
FoodCategory.Drink -> "DRINK"
7777
FoodCategory.Processed -> "PROCESSED"
78-
FoodCategory.Other -> "ETC"
78+
FoodCategory.Etc -> "ETC"
7979
}
8080

8181
/**

domain/src/main/kotlin/com/anddd/nevera/domain/model/ingredient/FoodCategory.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ package com.anddd.nevera.domain.model.ingredient
88
* @see com.anddd.nevera.feature.ingredient.main.iconRes
99
*/
1010
sealed interface FoodCategory {
11-
data object Vegetable : FoodCategory
11+
data object Veg : FoodCategory
1212
data object Fruit : FoodCategory
13-
data object MeatEgg : FoodCategory
14-
data object Seafood : FoodCategory
13+
data object MeatEggs : FoodCategory
14+
data object Sea : FoodCategory
1515
data object Dairy : FoodCategory
1616
data object Sauce : FoodCategory
17-
data object Beverage : FoodCategory
17+
data object Drink : FoodCategory
1818
data object Processed : FoodCategory
19-
data object Other : FoodCategory
19+
data object Etc : FoodCategory
2020

2121
companion object {
2222
/** 화면에 표시할 모든 카테고리 목록 (선언 순서 유지) */
2323
val entries: List<FoodCategory> = listOf(
24-
Vegetable, Fruit, MeatEgg, Seafood, Dairy, Sauce, Beverage, Processed, Other,
24+
Veg, Fruit, MeatEggs, Sea, Dairy, Sauce, Drink, Processed, Etc,
2525
)
2626
}
2727
}

domain/src/main/kotlin/com/anddd/nevera/domain/model/ingredient/OcrIngredient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ data class OcrIngredient(
2121
val cost: Int,
2222
) {
2323
companion object {
24-
val DEFAULT_CATEGORY = FoodCategory.Other
24+
val DEFAULT_CATEGORY = FoodCategory.Etc
2525
val DEFAULT_LOCATION = StorageLocation.Pantry
2626
}
2727
}

feature/fridge/src/main/kotlin/com/anddd/nevera/feature/fridge/main/component/FridgeCategoryFilterRow.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ private fun FridgeCategoryChip(
7979

8080
private val FoodCategory.labelRes: Int
8181
get() = when (this) {
82-
FoodCategory.Vegetable -> R.string.fridge_category_vegetable
82+
FoodCategory.Veg -> R.string.fridge_category_vegetable
8383
FoodCategory.Fruit -> R.string.fridge_category_fruit
84-
FoodCategory.MeatEgg -> R.string.fridge_category_meat_egg
85-
FoodCategory.Seafood -> R.string.fridge_category_seafood
84+
FoodCategory.MeatEggs -> R.string.fridge_category_meat_egg
85+
FoodCategory.Sea -> R.string.fridge_category_seafood
8686
FoodCategory.Dairy -> R.string.fridge_category_dairy
8787
FoodCategory.Sauce -> R.string.fridge_category_sauce
88-
FoodCategory.Beverage -> R.string.fridge_category_beverage
88+
FoodCategory.Drink -> R.string.fridge_category_beverage
8989
FoodCategory.Processed -> R.string.fridge_category_processed
90-
FoodCategory.Other -> R.string.fridge_category_other
90+
FoodCategory.Etc -> R.string.fridge_category_other
9191
}
9292

9393
@Preview(showBackground = true, widthDp = 360)

feature/ingredient/src/main/kotlin/com/anddd/nevera/feature/ingredient/main/FoodCategoryUiExt.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ import com.anddd.nevera.domain.model.ingredient.FoodCategory
1010
@Composable
1111
fun FoodCategory.displayName(): String = stringResource(
1212
when (this) {
13-
FoodCategory.Vegetable -> R.string.ingredient_category_vegetable
13+
FoodCategory.Veg -> R.string.ingredient_category_vegetable
1414
FoodCategory.Fruit -> R.string.ingredient_category_fruit
15-
FoodCategory.MeatEgg -> R.string.ingredient_category_meat_egg
16-
FoodCategory.Seafood -> R.string.ingredient_category_seafood
15+
FoodCategory.MeatEggs -> R.string.ingredient_category_meat_egg
16+
FoodCategory.Sea -> R.string.ingredient_category_seafood
1717
FoodCategory.Dairy -> R.string.ingredient_category_dairy
1818
FoodCategory.Sauce -> R.string.ingredient_category_sauce
19-
FoodCategory.Beverage -> R.string.ingredient_category_beverage
19+
FoodCategory.Drink -> R.string.ingredient_category_beverage
2020
FoodCategory.Processed -> R.string.ingredient_category_processed
21-
FoodCategory.Other -> R.string.ingredient_category_other
21+
FoodCategory.Etc -> R.string.ingredient_category_other
2222
}
2323
)
2424

2525
/** 카테고리 대표 이미지 리소스 ID */
2626
@DrawableRes
2727
fun FoodCategory.iconRes(): Int = when (this) {
28-
FoodCategory.Vegetable -> R.drawable.img_listcell_vegetable
28+
FoodCategory.Veg -> R.drawable.img_listcell_vegetable
2929
FoodCategory.Fruit -> R.drawable.img_listcell_fruit
30-
FoodCategory.MeatEgg -> R.drawable.img_listcell_meat
31-
FoodCategory.Seafood -> R.drawable.img_listcell_seafood
30+
FoodCategory.MeatEggs -> R.drawable.img_listcell_meat
31+
FoodCategory.Sea -> R.drawable.img_listcell_seafood
3232
FoodCategory.Dairy -> R.drawable.img_listcell_dairy
3333
FoodCategory.Sauce -> R.drawable.img_listcell_sauce
34-
FoodCategory.Beverage -> R.drawable.img_listcell_beverage
34+
FoodCategory.Drink -> R.drawable.img_listcell_beverage
3535
FoodCategory.Processed -> R.drawable.img_listcell_processed
36-
FoodCategory.Other -> R.drawable.img_listcell_etc
36+
FoodCategory.Etc -> R.drawable.img_listcell_etc
3737
}

feature/ingredient/src/main/kotlin/com/anddd/nevera/feature/ingredient/main/component/CategoryBottomSheet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private fun CategoryItem(
144144
private fun CategoryListPreview() {
145145
NeveraTheme {
146146
CategoryList(
147-
selectedCategory = FoodCategory.Beverage,
147+
selectedCategory = FoodCategory.Drink,
148148
onCategoryClick = {},
149149
)
150150
}

feature/ingredient/src/main/kotlin/com/anddd/nevera/feature/ingredient/main/component/IngredientContent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private fun IngredientContentPreview() {
307307
items = listOf(
308308
IngredientUiModel(
309309
name = "아침에주스 ABC 주스, 18개입",
310-
category = FoodCategory.Beverage,
310+
category = FoodCategory.Drink,
311311
location = StorageLocation.Fridge,
312312
quantity = 2,
313313
cost = 1000,

feature/ingredient/src/main/kotlin/com/anddd/nevera/feature/ingredient/main/component/ingredient/IngredientItemCard.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private fun IngredientItemCardSelectedPreview() {
120120
IngredientItemCard(
121121
item = IngredientUiModel(
122122
name = "아침에주스 ABC 주스, 18개입 과즙 음료",
123-
category = FoodCategory.Beverage,
123+
category = FoodCategory.Drink,
124124
location = StorageLocation.Fridge,
125125
quantity = 2,
126126
cost = 1000,

feature/main/src/main/kotlin/com/anddd/nevera/feature/main/home/FoodCategoryExt.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import com.anddd.nevera.feature.main.R
66

77
@DrawableRes
88
internal fun FoodCategory.iconRes(): Int = when (this) {
9-
FoodCategory.Vegetable -> R.drawable.img_listcell_vegetable
9+
FoodCategory.Veg -> R.drawable.img_listcell_vegetable
1010
FoodCategory.Fruit -> R.drawable.img_listcell_fruit
11-
FoodCategory.MeatEgg -> R.drawable.img_listcell_meat
12-
FoodCategory.Seafood -> R.drawable.img_listcell_seafood
11+
FoodCategory.MeatEggs -> R.drawable.img_listcell_meat
12+
FoodCategory.Sea -> R.drawable.img_listcell_seafood
1313
FoodCategory.Dairy -> R.drawable.img_listcell_dairy
1414
FoodCategory.Sauce -> R.drawable.img_listcell_sauce
15-
FoodCategory.Beverage -> R.drawable.img_listcell_beverage
15+
FoodCategory.Drink -> R.drawable.img_listcell_beverage
1616
FoodCategory.Processed -> R.drawable.img_listcell_processed
17-
FoodCategory.Other -> R.drawable.img_listcell_etc
17+
FoodCategory.Etc -> R.drawable.img_listcell_etc
1818
}

feature/main/src/main/kotlin/com/anddd/nevera/feature/main/home/component/IngredientItem.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private fun IngredientItemVegetablePreview() {
7979
ingredient = IngredientUiModel(
8080
id = 1L,
8181
name = "깐마늘",
82-
category = FoodCategory.Vegetable,
82+
category = FoodCategory.Veg,
8383
categoryName = "채소",
8484
quantity = 1,
8585
cost = 5600,
@@ -113,7 +113,7 @@ private fun IngredientItemMeatEggPreview() {
113113
ingredient = IngredientUiModel(
114114
id = 3L,
115115
name = "닭가슴살",
116-
category = FoodCategory.MeatEgg,
116+
category = FoodCategory.MeatEggs,
117117
categoryName = "육류/계란",
118118
quantity = 2,
119119
cost = 12000,
@@ -130,7 +130,7 @@ private fun IngredientItemSeafoodPreview() {
130130
ingredient = IngredientUiModel(
131131
id = 4L,
132132
name = "참치(생)",
133-
category = FoodCategory.Seafood,
133+
category = FoodCategory.Sea,
134134
categoryName = "해산물",
135135
quantity = 1,
136136
cost = 32000,
@@ -181,7 +181,7 @@ private fun IngredientItemBeveragePreview() {
181181
ingredient = IngredientUiModel(
182182
id = 7L,
183183
name = "코카콜라 제로",
184-
category = FoodCategory.Beverage,
184+
category = FoodCategory.Drink,
185185
categoryName = "음료",
186186
quantity = 6,
187187
cost = 4800,
@@ -215,7 +215,7 @@ private fun IngredientItemOtherPreview() {
215215
ingredient = IngredientUiModel(
216216
id = 9L,
217217
name = "기타 식재료",
218-
category = FoodCategory.Other,
218+
category = FoodCategory.Etc,
219219
categoryName = "기타",
220220
quantity = 1,
221221
cost = 2000,
@@ -232,7 +232,7 @@ private fun IngredientItemLongNamePreview() {
232232
ingredient = IngredientUiModel(
233233
id = 10L,
234234
name = "아주아주길다란이름의처음보는식재...",
235-
category = FoodCategory.Vegetable,
235+
category = FoodCategory.Veg,
236236
categoryName = "채소",
237237
quantity = 1,
238238
cost = 5600,

0 commit comments

Comments
 (0)