Skip to content

Commit cfc7f70

Browse files
authored
Merge pull request #57 from YAPP-Github/feature/#49-write_routine_with_api
[Feature/#49] 단일 루틴/단일 추천 루틴 API 연결 및 기존 API 호출부 점검
2 parents da4e368 + 94f1300 commit cfc7f70

File tree

36 files changed

+231
-124
lines changed

36 files changed

+231
-124
lines changed

app/src/main/java/com/threegap/bitnagil/MainNavHost.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.threegap.bitnagil
22

33
import androidx.compose.runtime.Composable
44
import androidx.compose.ui.Modifier
5+
import androidx.hilt.navigation.compose.hiltViewModel
56
import androidx.navigation.compose.NavHost
67
import androidx.navigation.compose.composable
78
import androidx.navigation.toRoute
@@ -15,6 +16,8 @@ import com.threegap.bitnagil.presentation.splash.SplashScreenContainer
1516
import com.threegap.bitnagil.presentation.terms.TermsAgreementScreenContainer
1617
import com.threegap.bitnagil.presentation.webview.BitnagilWebViewScreen
1718
import com.threegap.bitnagil.presentation.writeroutine.WriteRoutineScreenContainer
19+
import com.threegap.bitnagil.presentation.writeroutine.WriteRoutineViewModel
20+
import com.threegap.bitnagil.presentation.writeroutine.model.navarg.WriteRoutineScreenArg
1821

1922
@Composable
2023
fun MainNavHost(
@@ -162,8 +165,20 @@ fun MainNavHost(
162165
)
163166
}
164167

165-
composable<Route.WriteRoutine> {
168+
composable<Route.WriteRoutine> { navBackStackEntry ->
169+
val arg = navBackStackEntry.toRoute<Route.WriteRoutine>()
170+
val writeScreenNavArg = if (arg.isRegister) {
171+
WriteRoutineScreenArg.Add(baseRoutineId = arg.routineId)
172+
} else {
173+
WriteRoutineScreenArg.Edit(routineId = arg.routineId!!)
174+
}
175+
176+
val viewModel = hiltViewModel<WriteRoutineViewModel, WriteRoutineViewModel.Factory> { factory ->
177+
factory.create(writeScreenNavArg)
178+
}
179+
166180
WriteRoutineScreenContainer(
181+
viewModel = viewModel,
167182
navigateToBack = {
168183
navigator.navController.popBackStack()
169184
},

data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AuthRemoteDataSourceImpl @Inject constructor(
1818
}
1919

2020
override suspend fun submitAgreement(termsAgreementRequestDto: TermsAgreementRequestDto): Result<Unit> =
21-
safeApiCall {
21+
safeUnitApiCall {
2222
authService.submitAgreement(termsAgreementRequestDto)
2323
}
2424

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

3-
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
3+
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
44
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
55
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
66

77
interface EmotionDataSource {
8-
suspend fun getEmotions(): Result<GetEmotionsResponse>
8+
suspend fun getEmotions(): Result<List<EmotionDto>>
99
suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse>
1010
suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotionResponseDto>
1111
}

data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt

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

33
import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
5+
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
56
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
6-
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
77
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
88
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
99
import com.threegap.bitnagil.data.emotion.service.EmotionService
@@ -12,7 +12,7 @@ import javax.inject.Inject
1212
class EmotionDataSourceImpl @Inject constructor(
1313
private val emotionService: EmotionService,
1414
) : EmotionDataSource {
15-
override suspend fun getEmotions(): Result<GetEmotionsResponse> {
15+
override suspend fun getEmotions(): Result<List<EmotionDto>> {
1616
return safeApiCall {
1717
emotionService.getEmotions()
1818
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.threegap.bitnagil.data.emotion.model.dto
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class EmotionDto(
8+
@SerialName("emotionMarbleType")
9+
val emotionMarbleType: String,
10+
@SerialName("emotionMarbleName")
11+
val emotionMarbleName: String,
12+
@SerialName("imageUrl")
13+
val imageUrl: String,
14+
)

data/src/main/java/com/threegap/bitnagil/data/emotion/model/dto/EmotionRecommendedRoutineDto.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ data class EmotionRecommendedRoutineDto(
99
val recommendedRoutineId: Int,
1010
@SerialName("recommendedRoutineName")
1111
val recommendedRoutineName: String,
12-
@SerialName("routineDescription")
13-
val routineDescription: String,
14-
@SerialName("recommendedSubRoutines")
15-
val recommendedSubRoutines: List<EmotionRecommendedSubRoutineDto>,
12+
@SerialName("recommendedRoutineDescription")
13+
val recommendedRoutineDescription: String,
14+
@SerialName("recommendedSubRoutineSearchResult")
15+
val recommendedSubRoutineSearchResult: List<EmotionRecommendedSubRoutineDto>,
1616
)

data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/GetEmotionsResponse.kt

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

data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class EmotionRepositoryImpl @Inject constructor(
1212
) : EmotionRepository {
1313
override suspend fun getEmotions(): Result<List<Emotion>> {
1414
return emotionDataSource.getEmotions().map { response ->
15-
response.emotionMarbleTypes.mapNotNull {
16-
when (it) {
15+
response.mapNotNull {
16+
when (it.emotionMarbleType) {
1717
"CALM" -> Emotion.CALM
1818
"VITALITY" -> Emotion.VITALITY
1919
"LETHARGY" -> Emotion.LETHARGY

data/src/main/java/com/threegap/bitnagil/data/emotion/service/EmotionService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.threegap.bitnagil.data.emotion.service
22

3+
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
34
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
4-
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
55
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
66
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
77
import com.threegap.bitnagil.network.model.BaseResponse
@@ -12,7 +12,7 @@ import retrofit2.http.Query
1212

1313
interface EmotionService {
1414
@GET("/api/v1/emotion-marbles")
15-
suspend fun getEmotions(): BaseResponse<GetEmotionsResponse>
15+
suspend fun getEmotions(): BaseResponse<List<EmotionDto>>
1616

1717
@POST("/api/v1/emotion-marbles")
1818
suspend fun postEmotions(

data/src/main/java/com/threegap/bitnagil/data/onboarding/datasourceImpl/OnBoardingDataSourceImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.threegap.bitnagil.data.onboarding.datasourceImpl
22

33
import com.threegap.bitnagil.data.common.safeApiCall
4+
import com.threegap.bitnagil.data.common.safeUnitApiCall
45
import com.threegap.bitnagil.data.onboarding.datasource.OnBoardingDataSource
56
import com.threegap.bitnagil.data.onboarding.model.dto.OnBoardingAbstractDto
67
import com.threegap.bitnagil.data.onboarding.model.dto.OnBoardingAbstractTextDto
@@ -51,7 +52,7 @@ class OnBoardingDataSourceImpl @Inject constructor(
5152

5253
override suspend fun registerRecommendRoutineList(selectedRecommendRoutineIds: List<Int>): Result<Unit> {
5354
val registerRecommendRoutineListRequest = RegisterOnBoardingRecommendRoutinesRequest(recommendedRoutineIds = selectedRecommendRoutineIds)
54-
return safeApiCall {
55+
return safeUnitApiCall {
5556
onBoardingService.postOnBoardingRoutines(registerRecommendRoutineListRequest)
5657
}
5758
}

0 commit comments

Comments
 (0)