Skip to content

Commit 85eb3d1

Browse files
committed
Refactor: 추천 루틴 관련 모델 및 네이밍 변경
1 parent 89508e1 commit 85eb3d1

17 files changed

Lines changed: 68 additions & 81 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.threegap.bitnagil.data.recommendroutine.datasource
22

3-
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto
4-
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto
3+
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesResponse
4+
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineResponse
55

66
interface RecommendRoutineDataSource {
7-
suspend fun fetchRecommendRoutines(): Result<RecommendRoutinesDto>
8-
suspend fun getRecommendRoutine(recommendRoutineId: Long): Result<RecommendedRoutineDto>
7+
suspend fun fetchRecommendRoutines(): Result<RecommendRoutinesResponse>
8+
suspend fun getRecommendRoutine(recommendRoutineId: Long): Result<RecommendedRoutineResponse>
99
}

data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasourceImpl/RecommendRoutineDataSourceImpl.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ package com.threegap.bitnagil.data.recommendroutine.datasourceImpl
22

33
import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.recommendroutine.datasource.RecommendRoutineDataSource
5-
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto
6-
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto
5+
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesResponse
6+
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineResponse
77
import com.threegap.bitnagil.data.recommendroutine.service.RecommendRoutineService
88
import javax.inject.Inject
99

1010
class RecommendRoutineDataSourceImpl @Inject constructor(
1111
private val recommendRoutineService: RecommendRoutineService,
1212
) : RecommendRoutineDataSource {
1313

14-
override suspend fun fetchRecommendRoutines(): Result<RecommendRoutinesDto> =
14+
override suspend fun fetchRecommendRoutines(): Result<RecommendRoutinesResponse> =
1515
safeApiCall {
1616
recommendRoutineService.fetchRecommendRoutines()
1717
}
1818

19-
override suspend fun getRecommendRoutine(recommendRoutineId: Long): Result<RecommendedRoutineDto> =
19+
override suspend fun getRecommendRoutine(recommendRoutineId: Long): Result<RecommendedRoutineResponse> =
2020
safeApiCall {
2121
recommendRoutineService.getRecommendRoutine(recommendRoutineId)
2222
}

data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesDto.kt renamed to data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesResponse.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
package com.threegap.bitnagil.data.recommendroutine.model.response
22

3-
import com.threegap.bitnagil.domain.recommendroutine.model.EmotionMarbleType
3+
import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType
44
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory
55
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutines
66
import kotlinx.serialization.SerialName
77
import kotlinx.serialization.Serializable
88

99
@Serializable
10-
data class RecommendRoutinesDto(
10+
data class RecommendRoutinesResponse(
1111
@SerialName("recommendedRoutines")
12-
val recommendedRoutinesByCategory: Map<RecommendCategory, List<RecommendedRoutineDto>>,
12+
val recommendedRoutinesByCategory: Map<RecommendCategory, List<RecommendedRoutineResponse>>,
1313
@SerialName("emotionMarbleType")
1414
val emotionMarbleType: EmotionMarbleType?,
1515
)
1616

17-
fun RecommendRoutinesDto.toDomain(): RecommendRoutines =
17+
fun RecommendRoutinesResponse.toDomain(): RecommendRoutines =
1818
RecommendRoutines(
19-
recommendRoutinesByCategory = this.recommendedRoutinesByCategory.map { (category, routines) ->
20-
category to routines.map { it.toDomain() }
21-
}.toMap(),
19+
recommendRoutinesByCategory = this.recommendedRoutinesByCategory.mapValues { (_, routines) ->
20+
routines.map { it.toDomain() }
21+
},
2222
emotionMarbleType = this.emotionMarbleType,
2323
)

data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineDto.kt renamed to data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineResponse.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import kotlinx.serialization.SerialName
77
import kotlinx.serialization.Serializable
88

99
@Serializable
10-
data class RecommendedRoutineDto(
10+
data class RecommendedRoutineResponse(
1111
@SerialName("recommendedRoutineId")
1212
val recommendedRoutineId: Long,
1313
@SerialName("recommendedRoutineName")
@@ -21,16 +21,16 @@ data class RecommendedRoutineDto(
2121
@SerialName("recommendedRoutineType")
2222
val recommendedRoutineType: RecommendCategory,
2323
@SerialName("recommendedSubRoutineSearchResult")
24-
val recommendedSubRoutineSearchResult: List<RecommendedSubRoutineDto>,
24+
val recommendedSubRoutineSearchResult: List<RecommendedSubRoutineResponse>,
2525
)
2626

27-
fun RecommendedRoutineDto.toDomain(): RecommendRoutine =
27+
fun RecommendedRoutineResponse.toDomain(): RecommendRoutine =
2828
RecommendRoutine(
2929
id = this.recommendedRoutineId,
3030
name = this.recommendedRoutineName,
3131
description = this.recommendedRoutineDescription,
3232
level = this.recommendedRoutineLevel,
3333
executionTime = this.executionTime,
34-
recommendedRoutineType = this.recommendedRoutineType,
35-
recommendSubRoutines = this.recommendedSubRoutineSearchResult.map { it.toDomain() },
34+
category = this.recommendedRoutineType,
35+
subRoutines = this.recommendedSubRoutineSearchResult.map { it.toDomain() },
3636
)

data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineDto.kt renamed to data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineResponse.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import kotlinx.serialization.SerialName
55
import kotlinx.serialization.Serializable
66

77
@Serializable
8-
data class RecommendedSubRoutineDto(
8+
data class RecommendedSubRoutineResponse(
99
@SerialName("recommendedSubRoutineId")
1010
val recommendedSubRoutineId: Long,
1111
@SerialName("recommendedSubRoutineName")
1212
val recommendedSubRoutineName: String,
1313
)
1414

15-
fun RecommendedSubRoutineDto.toDomain(): RecommendSubRoutine =
15+
fun RecommendedSubRoutineResponse.toDomain(): RecommendSubRoutine =
1616
RecommendSubRoutine(
1717
id = recommendedSubRoutineId,
1818
name = recommendedSubRoutineName,
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package com.threegap.bitnagil.data.recommendroutine.service
22

3-
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto
4-
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto
3+
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesResponse
4+
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineResponse
55
import com.threegap.bitnagil.network.model.BaseResponse
66
import retrofit2.http.GET
77
import retrofit2.http.Path
88

99
interface RecommendRoutineService {
1010
@GET("/api/v1/recommend-routines")
11-
suspend fun fetchRecommendRoutines(): BaseResponse<RecommendRoutinesDto>
11+
suspend fun fetchRecommendRoutines(): BaseResponse<RecommendRoutinesResponse>
1212

1313
@GET("/api/v1/recommend-routines/{recommendedRoutineId}")
1414
suspend fun getRecommendRoutine(
1515
@Path("recommendedRoutineId") recommendedRoutineId: Long,
16-
): BaseResponse<RecommendedRoutineDto>
16+
): BaseResponse<RecommendedRoutineResponse>
1717
}

data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineScheduleResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ data class RoutineScheduleResponse(
1212

1313
fun RoutineScheduleResponse.toDomain(): RoutineSchedule =
1414
RoutineSchedule(
15-
dailyRoutines = this.dailyRoutines.mapValues { (_, dailyRoutinesResponse) -> dailyRoutinesResponse.toDomain() }
15+
dailyRoutines = this.dailyRoutines.mapValues { (_, dailyRoutinesResponse) -> dailyRoutinesResponse.toDomain() },
1616
)

domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/EmotionMarbleType.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.

domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutine.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ data class RecommendRoutine(
66
val description: String,
77
val level: RecommendLevel,
88
val executionTime: String,
9-
val recommendedRoutineType: RecommendCategory,
10-
val recommendSubRoutines: List<RecommendSubRoutine>,
9+
val category: RecommendCategory,
10+
val subRoutines: List<RecommendSubRoutine>,
1111
)

domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutines.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.threegap.bitnagil.domain.recommendroutine.model
22

3+
import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType
4+
35
data class RecommendRoutines(
46
val recommendRoutinesByCategory: Map<RecommendCategory, List<RecommendRoutine>>,
57
val emotionMarbleType: EmotionMarbleType?,

0 commit comments

Comments
 (0)