Skip to content

Commit 96fe033

Browse files
committed
Refactor: RepeatDay enum 자동 직렬화 적용
1 parent fad0b6d commit 96fe033

6 files changed

Lines changed: 31 additions & 26 deletions

File tree

data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/EditRoutineRequest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.threegap.bitnagil.data.writeroutine.model.request
22

3+
import com.threegap.bitnagil.domain.writeroutine.model.RepeatDay
34
import com.threegap.bitnagil.domain.writeroutine.model.RoutineUpdateType
45
import kotlinx.serialization.SerialName
56
import kotlinx.serialization.Serializable
@@ -13,7 +14,7 @@ data class EditRoutineRequest(
1314
@SerialName("routineName")
1415
val routineName: String,
1516
@SerialName("repeatDay")
16-
val repeatDay: List<String>,
17+
val repeatDay: List<RepeatDay>,
1718
@SerialName("routineStartDate")
1819
val routineStartDate: String,
1920
@SerialName("routineEndDate")

data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.threegap.bitnagil.data.writeroutine.model.request
22

3+
import com.threegap.bitnagil.domain.writeroutine.model.RepeatDay
34
import kotlinx.serialization.SerialName
45
import kotlinx.serialization.Serializable
56

@@ -8,7 +9,7 @@ data class RegisterRoutineRequest(
89
@SerialName("routineName")
910
val routineName: String,
1011
@SerialName("repeatDay")
11-
val repeatDay: List<String>,
12+
val repeatDay: List<RepeatDay>,
1213
@SerialName("routineStartDate")
1314
val routineStartDate: String,
1415
@SerialName("routineEndDate")

data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class WriteRoutineRepositoryImpl @Inject constructor(
2828
): Result<Unit> {
2929
val request = RegisterRoutineRequest(
3030
routineName = name,
31-
repeatDay = repeatDay.map { it.fullName },
31+
repeatDay = repeatDay.map { it },
3232
executionTime = startTime.toString(),
3333
routineStartDate = startDate.toString(),
3434
routineEndDate = endDate.toString(),
@@ -56,7 +56,7 @@ class WriteRoutineRepositoryImpl @Inject constructor(
5656
routineId = routineId,
5757
updateApplyDate = routineUpdateType,
5858
routineName = name,
59-
repeatDay = repeatDay.map { it.fullName },
59+
repeatDay = repeatDay.map { it },
6060
executionTime = startTime.toString(),
6161
routineStartDate = startDate.toString(),
6262
routineEndDate = endDate.toString(),
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.threegap.bitnagil.domain.writeroutine.model
22

3-
enum class RepeatDay(val fullName: String) {
4-
MON(fullName = "MONDAY"),
5-
TUE(fullName = "TUESDAY"),
6-
WED(fullName = "WEDNESDAY"),
7-
THU(fullName = "THURSDAY"),
8-
FRI(fullName = "FRIDAY"),
9-
SAT(fullName = "SATURDAY"),
10-
SUN(fullName = "SUNDAY"),
3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
6+
enum class RepeatDay {
7+
MONDAY,
8+
TUESDAY,
9+
WEDNESDAY,
10+
THURSDAY,
11+
FRIDAY,
12+
SATURDAY,
13+
SUNDAY,
1114
;
1215
}

presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineViewModel.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ class WriteRoutineViewModel @AssistedInject constructor(
341341

342342
val repeatDay = when (currentState.repeatType) {
343343
RepeatType.DAILY -> listOf(
344-
RepeatDay.MON,
345-
RepeatDay.TUE,
346-
RepeatDay.WED,
347-
RepeatDay.THU,
348-
RepeatDay.FRI,
349-
RepeatDay.SAT,
350-
RepeatDay.SUN,
344+
RepeatDay.MONDAY,
345+
RepeatDay.TUESDAY,
346+
RepeatDay.WEDNESDAY,
347+
RepeatDay.THURSDAY,
348+
RepeatDay.FRIDAY,
349+
RepeatDay.SATURDAY,
350+
RepeatDay.SUNDAY,
351351
)
352352

353353
RepeatType.DAY ->

presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/Day.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ enum class Day(val text: String) {
1515

1616
fun toRepeatDay(): RepeatDay {
1717
return when (this) {
18-
MON -> RepeatDay.MON
19-
TUE -> RepeatDay.TUE
20-
WED -> RepeatDay.WED
21-
THU -> RepeatDay.THU
22-
FRI -> RepeatDay.FRI
23-
SAT -> RepeatDay.SAT
24-
SUN -> RepeatDay.SUN
18+
MON -> RepeatDay.MONDAY
19+
TUE -> RepeatDay.TUESDAY
20+
WED -> RepeatDay.WEDNESDAY
21+
THU -> RepeatDay.THURSDAY
22+
FRI -> RepeatDay.FRIDAY
23+
SAT -> RepeatDay.SATURDAY
24+
SUN -> RepeatDay.SUNDAY
2525
}
2626
}
2727

0 commit comments

Comments
 (0)