Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion app/src/main/java/com/threegap/bitnagil/MainNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.threegap.bitnagil

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
Expand All @@ -15,6 +16,8 @@ import com.threegap.bitnagil.presentation.splash.SplashScreenContainer
import com.threegap.bitnagil.presentation.terms.TermsAgreementScreenContainer
import com.threegap.bitnagil.presentation.webview.BitnagilWebViewScreen
import com.threegap.bitnagil.presentation.writeroutine.WriteRoutineScreenContainer
import com.threegap.bitnagil.presentation.writeroutine.WriteRoutineViewModel
import com.threegap.bitnagil.presentation.writeroutine.model.navarg.WriteRoutineScreenArg

@Composable
fun MainNavHost(
Expand Down Expand Up @@ -162,8 +165,20 @@ fun MainNavHost(
)
}

composable<Route.WriteRoutine> {
composable<Route.WriteRoutine> { navBackStackEntry ->
val arg = navBackStackEntry.toRoute<Route.WriteRoutine>()
val writeScreenNavArg = if (arg.isRegister) {
WriteRoutineScreenArg.Add(baseRoutineId = arg.routineId)
} else {
WriteRoutineScreenArg.Edit(routineId = arg.routineId!!)
}

val viewModel = hiltViewModel<WriteRoutineViewModel, WriteRoutineViewModel.Factory> { factory ->
factory.create(writeScreenNavArg)
}

WriteRoutineScreenContainer(
viewModel = viewModel,
navigateToBack = {
navigator.navController.popBackStack()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthRemoteDataSourceImpl @Inject constructor(
}

override suspend fun submitAgreement(termsAgreementRequestDto: TermsAgreementRequestDto): Result<Unit> =
safeApiCall {
safeUnitApiCall {
authService.submitAgreement(termsAgreementRequestDto)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.threegap.bitnagil.data.emotion.datasource

import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse

interface EmotionDataSource {
suspend fun getEmotions(): Result<GetEmotionsResponse>
suspend fun getEmotions(): Result<List<EmotionDto>>
suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse>
suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotionResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.threegap.bitnagil.data.emotion.datasourceImpl

import com.threegap.bitnagil.data.common.safeApiCall
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
import com.threegap.bitnagil.data.emotion.service.EmotionService
Expand All @@ -12,7 +12,7 @@ import javax.inject.Inject
class EmotionDataSourceImpl @Inject constructor(
private val emotionService: EmotionService,
) : EmotionDataSource {
override suspend fun getEmotions(): Result<GetEmotionsResponse> {
override suspend fun getEmotions(): Result<List<EmotionDto>> {
return safeApiCall {
emotionService.getEmotions()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.threegap.bitnagil.data.emotion.model.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class EmotionDto(
@SerialName("emotionMarbleType")
val emotionMarbleType: String,
@SerialName("emotionMarbleName")
val emotionMarbleName: String,
@SerialName("imageUrl")
val imageUrl: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ data class EmotionRecommendedRoutineDto(
val recommendedRoutineId: Int,
@SerialName("recommendedRoutineName")
val recommendedRoutineName: String,
@SerialName("routineDescription")
val routineDescription: String,
@SerialName("recommendedSubRoutines")
val recommendedSubRoutines: List<EmotionRecommendedSubRoutineDto>,
@SerialName("recommendedRoutineDescription")
val recommendedRoutineDescription: String,
@SerialName("recommendedSubRoutineSearchResult")
val recommendedSubRoutineSearchResult: List<EmotionRecommendedSubRoutineDto>,
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class EmotionRepositoryImpl @Inject constructor(
) : EmotionRepository {
override suspend fun getEmotions(): Result<List<Emotion>> {
return emotionDataSource.getEmotions().map { response ->
response.emotionMarbleTypes.mapNotNull {
when (it) {
response.mapNotNull {
when (it.emotionMarbleType) {
"CALM" -> Emotion.CALM
"VITALITY" -> Emotion.VITALITY
"LETHARGY" -> Emotion.LETHARGY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.threegap.bitnagil.data.emotion.service

import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
import com.threegap.bitnagil.network.model.BaseResponse
Expand All @@ -12,7 +12,7 @@ import retrofit2.http.Query

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

@POST("/api/v1/emotion-marbles")
suspend fun postEmotions(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.threegap.bitnagil.data.onboarding.datasourceImpl

import com.threegap.bitnagil.data.common.safeApiCall
import com.threegap.bitnagil.data.common.safeUnitApiCall
import com.threegap.bitnagil.data.onboarding.datasource.OnBoardingDataSource
import com.threegap.bitnagil.data.onboarding.model.dto.OnBoardingAbstractDto
import com.threegap.bitnagil.data.onboarding.model.dto.OnBoardingAbstractTextDto
Expand Down Expand Up @@ -51,7 +52,7 @@ class OnBoardingDataSourceImpl @Inject constructor(

override suspend fun registerRecommendRoutineList(selectedRecommendRoutineIds: List<Int>): Result<Unit> {
val registerRecommendRoutineListRequest = RegisterOnBoardingRecommendRoutinesRequest(recommendedRoutineIds = selectedRecommendRoutineIds)
return safeApiCall {
return safeUnitApiCall {
onBoardingService.postOnBoardingRoutines(registerRecommendRoutineListRequest)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ data class OnBoardingItemDto(

companion object {
val Morning = OnBoardingItemDto(
id = "MORNING",
id = "08:00:00",
title = "아침을 잘 시작하고 싶어요",
description = null,
)

val Evening = OnBoardingItemDto(
id = "EVENING",
id = "20:00:00",
title = "저녁을 편안하게 마무리하고 싶어요",
description = null,
)

val Nothing = OnBoardingItemDto(
id = "NOTHING",
id = "00:00:00",
title = "언제든 상관 없어요",
description = null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ data class OnBoardingRecommendRoutineDto(
val recommendedRoutineId: Int,
@SerialName("recommendedRoutineName")
val recommendedRoutineName: String,
@SerialName("routineDescription")
val routineDescription: String,
@SerialName("recommendedSubRoutines")
val recommendedSubRoutines: List<OnBoardingRecommendSubRoutineDto>,
@SerialName("recommendedRoutineDescription")
val recommendedRoutineDescription: String,
@SerialName("recommendedSubRoutineSearchResult")
val recommendedSubRoutineSearchResult: List<OnBoardingRecommendSubRoutineDto>,
) {
fun toOnBoardingRecommendRoutine(): OnBoardingRecommendRoutine {
return OnBoardingRecommendRoutine(
id = "$recommendedRoutineId",
name = recommendedRoutineName,
description = routineDescription,
description = recommendedRoutineDescription,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.threegap.bitnagil.data.recommendroutine.datasource

import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto

interface RecommendRoutineDataSource {
suspend fun fetchRecommendRoutines(): Result<RecommendRoutinesDto>
suspend fun getRecommendRoutine(recommendRoutineId: Int): Result<RecommendedRoutineDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.recommendroutine.datasourceImpl
import com.threegap.bitnagil.data.common.safeApiCall
import com.threegap.bitnagil.data.recommendroutine.datasource.RecommendRoutineDataSource
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto
import com.threegap.bitnagil.data.recommendroutine.service.RecommendRoutineService
import javax.inject.Inject

Expand All @@ -14,4 +15,9 @@ class RecommendRoutineDataSourceImpl @Inject constructor(
safeApiCall {
recommendRoutineService.fetchRecommendRoutines()
}

override suspend fun getRecommendRoutine(recommendRoutineId: Int): Result<RecommendedRoutineDto> =
safeApiCall {
recommendRoutineService.getRecommendRoutine(recommendRoutineId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.threegap.bitnagil.data.recommendroutine.repositoryImpl

import com.threegap.bitnagil.data.recommendroutine.datasource.RecommendRoutineDataSource
import com.threegap.bitnagil.data.recommendroutine.model.response.toDomain
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutine
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutines
import com.threegap.bitnagil.domain.recommendroutine.repository.RecommendRoutineRepository
import javax.inject.Inject
Expand All @@ -12,4 +13,13 @@ class RecommendRoutineRepositoryImpl @Inject constructor(
override suspend fun fetchRecommendRoutines(): Result<RecommendRoutines> =
recommendRoutineDataSource.fetchRecommendRoutines()
.map { it.toDomain() }

override suspend fun getRecommendRoutine(recommendRoutineId: String): Result<RecommendRoutine> {
val recommendRoutineIdInt = recommendRoutineId.toIntOrNull() ?: return Result.failure(
IllegalArgumentException("recommendRoutineId is not a valid integer"),
)

return recommendRoutineDataSource.getRecommendRoutine(recommendRoutineIdInt)
.map { it.toDomain() }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.threegap.bitnagil.data.recommendroutine.service

import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto
import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto
import com.threegap.bitnagil.network.model.BaseResponse
import retrofit2.http.GET
import retrofit2.http.Path

interface RecommendRoutineService {
@GET("/api/v1/recommend-routines")
suspend fun fetchRecommendRoutines(): BaseResponse<RecommendRoutinesDto>

@GET("/api/v1/recommend-routines/{recommendedRoutineId}")
suspend fun getRecommendRoutine(
@Path("recommendedRoutineId") recommendedRoutineId: Int,
): BaseResponse<RecommendedRoutineDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package com.threegap.bitnagil.data.routine.datasource

import com.threegap.bitnagil.data.routine.model.request.RoutineByDayDeletionRequestDto
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
import com.threegap.bitnagil.data.routine.model.response.RoutineDto
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto

interface RoutineRemoteDataSource {
suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result<RoutinesResponseDto>
suspend fun syncRoutineCompletion(routineCompletionRequestDto: RoutineCompletionRequestDto): Result<Unit>
suspend fun deleteRoutine(routineId: String): Result<Unit>
suspend fun deleteRoutineByDay(routineByDayDeletionRequestDto: RoutineByDayDeletionRequestDto): Result<Unit>
suspend fun getRoutine(routineId: String): Result<RoutineDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.threegap.bitnagil.data.common.safeUnitApiCall
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
import com.threegap.bitnagil.data.routine.model.request.RoutineByDayDeletionRequestDto
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
import com.threegap.bitnagil.data.routine.model.response.RoutineDto
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
import com.threegap.bitnagil.data.routine.service.RoutineService
import javax.inject.Inject
Expand All @@ -31,4 +32,9 @@ class RoutineRemoteDataSourceImpl @Inject constructor(
safeUnitApiCall {
routineService.deleteRoutineByDay(routineByDayDeletionRequestDto)
}

override suspend fun getRoutine(routineId: String): Result<RoutineDto> =
safeApiCall {
routineService.getRoutine(routineId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal fun RoutineDto.toDomain() =
historySeq = this.historySeq,
routineName = this.routineName,
executionTime = this.executionTime,
subRoutines = this.subRoutines.map { it.toDomain() },
subRoutines = this.subRoutines.sortedBy { it.sortOrder }.map { it.toDomain() },
isModified = this.isModified,
routineCompletionId = this.routineCompletionId,
isCompleted = this.isCompleted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
import com.threegap.bitnagil.data.routine.mapper.toDomain
import com.threegap.bitnagil.data.routine.mapper.toDto
import com.threegap.bitnagil.data.routine.model.request.toDto
import com.threegap.bitnagil.domain.routine.model.Routine
import com.threegap.bitnagil.domain.routine.model.RoutineByDayDeletion
import com.threegap.bitnagil.domain.routine.model.RoutineCompletion
import com.threegap.bitnagil.domain.routine.model.Routines
Expand All @@ -23,6 +24,9 @@ class RoutineRepositoryImpl @Inject constructor(
override suspend fun deleteRoutine(routineId: String): Result<Unit> =
routineRemoteDataSource.deleteRoutine(routineId)

override suspend fun getRoutine(routineId: String): Result<Routine> =
routineRemoteDataSource.getRoutine(routineId).map { it.toDomain() }

override suspend fun deleteRoutineByDay(routineByDayDeletion: RoutineByDayDeletion): Result<Unit> =
routineRemoteDataSource.deleteRoutineByDay(routineByDayDeletion.toDto())
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.threegap.bitnagil.data.routine.service

import com.threegap.bitnagil.data.routine.model.request.RoutineByDayDeletionRequestDto
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
import com.threegap.bitnagil.data.routine.model.response.RoutineDto
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
import com.threegap.bitnagil.network.model.BaseResponse
import retrofit2.http.Body
Expand Down Expand Up @@ -29,6 +30,11 @@ interface RoutineService {
@Path("routineId") routineId: String,
): BaseResponse<Unit>

@GET("/api/v1/routines/{routineId}")
suspend fun getRoutine(
@Path("routineId") routineId: String,
): BaseResponse<RoutineDto>

@HTTP(method = "DELETE", path = "/api/v1/routines/day", hasBody = true)
suspend fun deleteRoutineByDay(
@Body request: RoutineByDayDeletionRequestDto,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.threegap.bitnagil.data.writeroutine.datasource

import com.threegap.bitnagil.data.writeroutine.model.dto.RoutineDto
import com.threegap.bitnagil.data.writeroutine.model.request.EditRoutineRequest
import com.threegap.bitnagil.data.writeroutine.model.request.RegisterRoutineRequest

interface WriteRoutineDataSource {
suspend fun registerRoutine(request: RegisterRoutineRequest): Result<Unit>
suspend fun editRoutine(request: EditRoutineRequest): Result<Unit>
suspend fun getRoutine(routineId: String): Result<RoutineDto>
}
Loading