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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import com.threegap.bitnagil.data.recommendroutine.datasource.RecommendRoutineDa
import com.threegap.bitnagil.data.recommendroutine.datasourceImpl.RecommendRoutineDataSourceImpl
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
import com.threegap.bitnagil.data.routine.datasourceImpl.RoutineRemoteDataSourceImpl
import com.threegap.bitnagil.data.user.datasource.UserDataSource
import com.threegap.bitnagil.data.user.datasourceImpl.UserDataSourceImpl
import com.threegap.bitnagil.data.writeroutine.datasource.WriteRoutineDataSource
import com.threegap.bitnagil.data.writeroutine.datasourceImpl.WriteRoutineDataSourceImpl
import dagger.Binds
Expand Down Expand Up @@ -48,6 +50,10 @@ abstract class DataSourceModule {
@Singleton
abstract fun bindWriteRoutineDataSource(writeRoutineDataSourceImpl: WriteRoutineDataSourceImpl): WriteRoutineDataSource

@Binds
@Singleton
abstract fun bindUserDataSource(userDataSourceImpl: UserDataSourceImpl): UserDataSource

@Binds
@Singleton
abstract fun bindRecommendRoutineDataSource(recommendRoutineDataSourceImpl: RecommendRoutineDataSourceImpl): RecommendRoutineDataSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import com.threegap.bitnagil.data.emotion.repositoryImpl.EmotionRepositoryImpl
import com.threegap.bitnagil.data.onboarding.repositoryImpl.OnBoardingRepositoryImpl
import com.threegap.bitnagil.data.recommendroutine.repositoryImpl.RecommendRoutineRepositoryImpl
import com.threegap.bitnagil.data.routine.repositoryImpl.RoutineRepositoryImpl
import com.threegap.bitnagil.data.user.repositoryImpl.UserRepositoryImpl
import com.threegap.bitnagil.data.writeroutine.repositoryImpl.WriteRoutineRepositoryImpl
import com.threegap.bitnagil.domain.auth.repository.AuthRepository
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
import com.threegap.bitnagil.domain.onboarding.repository.OnBoardingRepository
import com.threegap.bitnagil.domain.recommendroutine.repository.RecommendRoutineRepository
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
import com.threegap.bitnagil.domain.user.repository.UserRepository
import com.threegap.bitnagil.domain.writeroutine.repository.WriteRoutineRepository
import dagger.Binds
import dagger.Module
Expand Down Expand Up @@ -42,6 +44,10 @@ abstract class RepositoryModule {
@Singleton
abstract fun bindWriteRoutineRepository(writeRoutineRepositoryImpl: WriteRoutineRepositoryImpl): WriteRoutineRepository

@Binds
@Singleton
abstract fun bindUserRepository(userRepositoryImpl: UserRepositoryImpl): UserRepository

@Binds
@Singleton
abstract fun bindRecommendRoutineRepository(recommendRoutineRepositoryImpl: RecommendRoutineRepositoryImpl): RecommendRoutineRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.threegap.bitnagil.data.emotion.service.EmotionService
import com.threegap.bitnagil.data.onboarding.service.OnBoardingService
import com.threegap.bitnagil.data.recommendroutine.service.RecommendRoutineService
import com.threegap.bitnagil.data.routine.service.RoutineService
import com.threegap.bitnagil.data.user.service.UserService
import com.threegap.bitnagil.data.writeroutine.service.WriteRoutineService
import com.threegap.bitnagil.di.core.Auth
import com.threegap.bitnagil.di.core.NoneAuth
Expand Down Expand Up @@ -50,6 +51,11 @@ object ServiceModule {
fun provideReissueService(@NoneAuth retrofit: Retrofit): ReissueService =
retrofit.create(ReissueService::class.java)

@Provides
@Singleton
fun provideUserService(@Auth retrofit: Retrofit): UserService =
retrofit.create(UserService::class.java)

@Provides
@Singleton
fun provideRecommendRoutineService(@Auth retrofit: Retrofit): RecommendRoutineService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ data class AuthToken(
val accessToken: String,
@SerialName("refreshToken")
val refreshToken: String,
@SerialName("role") // todo: 제거 예정
val role: String,
)
Original file line number Diff line number Diff line change
@@ -1,9 +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.response.MyEmotionResponseDto
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse

interface EmotionDataSource {
suspend fun getEmotions(): Result<GetEmotionsResponse>
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 @@ -4,6 +4,7 @@ import com.threegap.bitnagil.data.common.safeApiCall
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
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
import javax.inject.Inject
Expand All @@ -23,4 +24,9 @@ class EmotionDataSourceImpl @Inject constructor(
emotionService.postEmotions(registerEmotionRequest)
}
}

override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotionResponseDto> =
safeApiCall {
emotionService.getMyEmotionMarble(currentDate)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.threegap.bitnagil.data.emotion.model.response

import com.threegap.bitnagil.domain.emotion.model.Emotion
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class MyEmotionResponseDto(
@SerialName("emotionMarbleType")
val emotionMarbleType: String?,
@SerialName("emotionMarbleName")
val emotionMarbleName: String?,
@SerialName("imageUrl")
val imageUrl: String?,
)

fun MyEmotionResponseDto.toDomain(): MyEmotion =
MyEmotion(
emotionMarbleType = emotionMarbleType?.let { Emotion.valueOf(it) },
emotionMarbleName = emotionMarbleName,
imageUrl = imageUrl,
)
Comment thread
wjdrjs00 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.threegap.bitnagil.data.emotion.repositoryImpl

import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
import com.threegap.bitnagil.data.emotion.model.response.toDomain
import com.threegap.bitnagil.domain.emotion.model.Emotion
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
import javax.inject.Inject

Expand Down Expand Up @@ -36,4 +38,7 @@ class EmotionRepositoryImpl @Inject constructor(

return emotionDataSource.registerEmotion(selectedEmotion).map { _ -> }
}

override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion> =
emotionDataSource.getMyEmotionMarble(currentDate).map { it.toDomain() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package com.threegap.bitnagil.data.emotion.service

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
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

interface EmotionService {
@GET("/api/v1/emotion-marbles")
Expand All @@ -16,4 +18,9 @@ interface EmotionService {
suspend fun postEmotions(
@Body request: RegisterEmotionRequest,
): BaseResponse<RegisterEmotionResponse>

@GET("/api/v1/emotion-marbles/me")
suspend fun getMyEmotionMarble(
@Query("searchDate") date: String,
): BaseResponse<MyEmotionResponseDto>
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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.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>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.routine.datasourceImpl
import com.threegap.bitnagil.data.common.safeApiCall
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.RoutinesResponseDto
import com.threegap.bitnagil.data.routine.service.RoutineService
Expand All @@ -25,4 +26,9 @@ class RoutineRemoteDataSourceImpl @Inject constructor(
safeUnitApiCall {
routineService.deleteRoutine(routineId)
}

override suspend fun deleteRoutineByDay(routineByDayDeletionRequestDto: RoutineByDayDeletionRequestDto): Result<Unit> =
safeUnitApiCall {
routineService.deleteRoutineByDay(routineByDayDeletionRequestDto)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal fun RoutineDto.toDomain() =
executionTime = this.executionTime,
subRoutines = this.subRoutines.map { it.toDomain() },
isModified = this.isModified,
routineCompletionId = this.routineCompletionId,
isCompleted = this.isCompleted,
repeatDay = this.repeatDay.map { DayOfWeek.fromString(it) },
routineType = RoutineType.fromString(this.routineType),
Expand All @@ -41,6 +42,7 @@ internal fun SubRoutineDto.toDomain() =
subRoutineName = this.subRoutineName,
isModified = this.isModified,
sortOrder = this.sortOrder,
routineCompletionId = this.routineCompletionId,
isCompleted = this.isCompleted,
routineType = RoutineType.fromString(this.routineType),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.threegap.bitnagil.data.routine.model.request

import com.threegap.bitnagil.domain.routine.model.RoutineByDayDeletion
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class RoutineByDayDeletionRequestDto(
@SerialName("routineCompletionId")
val routineCompletionId: Int?,
@SerialName("routineId")
val routineId: String,
@SerialName("subRoutineInfosForDelete")
val subRoutineInfosForDelete: List<SubRoutineDeletionInfoDto>,
@SerialName("performedDate")
val performedDate: String,
@SerialName("historySeq")
val historySeq: Int,
)

fun RoutineByDayDeletion.toDto() =
RoutineByDayDeletionRequestDto(
routineCompletionId = this.routineCompletionId,
routineId = this.routineId,
subRoutineInfosForDelete = this.subRoutineInfosForDelete.map { it.toDto() },
performedDate = this.performedDate,
historySeq = this.historySeq,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.threegap.bitnagil.data.routine.model.request

import com.threegap.bitnagil.domain.routine.model.SubRoutineDeletionInfo
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class SubRoutineDeletionInfoDto(
@SerialName("routineCompletionId")
val routineCompletionId: Int?,
@SerialName("subRoutineId")
val subRoutineId: String,
)

fun SubRoutineDeletionInfo.toDto() =
SubRoutineDeletionInfoDto(
routineCompletionId = this.routineCompletionId,
subRoutineId = this.subRoutineId,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ data class RoutineDto(
val subRoutines: List<SubRoutineDto>,
@SerialName("modifiedYn")
val isModified: Boolean,
@SerialName("routineCompletionId")
val routineCompletionId: Int?,
@SerialName("completeYn")
val isCompleted: Boolean,
@SerialName("routineType")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ data class SubRoutineDto(
val isModified: Boolean,
@SerialName("sortOrder")
val sortOrder: Int,
@SerialName("routineCompletionId")
val routineCompletionId: Int?,
@SerialName("completeYn")
val isCompleted: Boolean,
@SerialName("routineType")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.threegap.bitnagil.data.routine.repositoryImpl
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.RoutineByDayDeletion
import com.threegap.bitnagil.domain.routine.model.RoutineCompletion
import com.threegap.bitnagil.domain.routine.model.Routines
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
Expand All @@ -20,4 +22,7 @@ class RoutineRepositoryImpl @Inject constructor(

override suspend fun deleteRoutine(routineId: String): Result<Unit> =
routineRemoteDataSource.deleteRoutine(routineId)

override suspend fun deleteRoutineByDay(routineByDayDeletion: RoutineByDayDeletion): Result<Unit> =
routineRemoteDataSource.deleteRoutineByDay(routineByDayDeletion.toDto())
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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.RoutinesResponseDto
import com.threegap.bitnagil.network.model.BaseResponse
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.HTTP
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
Expand All @@ -26,4 +28,9 @@ interface RoutineService {
suspend fun deleteRoutine(
@Path("routineId") routineId: String,
): BaseResponse<Unit>

@HTTP(method = "DELETE", path = "/api/v1/routines/day", hasBody = true)
suspend fun deleteRoutineByDay(
@Body request: RoutineByDayDeletionRequestDto,
): BaseResponse<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.threegap.bitnagil.data.user.datasource

import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto

interface UserDataSource {
suspend fun fetchUserProfile(): Result<UserProfileResponseDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.threegap.bitnagil.data.user.datasourceImpl

import com.threegap.bitnagil.data.common.safeApiCall
import com.threegap.bitnagil.data.user.datasource.UserDataSource
import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto
import com.threegap.bitnagil.data.user.service.UserService
import javax.inject.Inject

class UserDataSourceImpl @Inject constructor(
private val userService: UserService,
) : UserDataSource {
override suspend fun fetchUserProfile(): Result<UserProfileResponseDto> =
safeApiCall {
userService.fetchUserProfile()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.threegap.bitnagil.data.user.model.response

import com.threegap.bitnagil.domain.user.model.UserProfile
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserProfileResponseDto(
@SerialName("nickname")
val nickname: String,
)

fun UserProfileResponseDto.toDomain() =
UserProfile(
nickname = this.nickname,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.threegap.bitnagil.data.user.repositoryImpl

import com.threegap.bitnagil.data.user.datasource.UserDataSource
import com.threegap.bitnagil.data.user.model.response.toDomain
import com.threegap.bitnagil.domain.user.model.UserProfile
import com.threegap.bitnagil.domain.user.repository.UserRepository
import javax.inject.Inject

class UserRepositoryImpl @Inject constructor(
private val userDataSource: UserDataSource,
) : UserRepository {
override suspend fun fetchUserProfile(): Result<UserProfile> =
userDataSource.fetchUserProfile().map { it.toDomain() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.threegap.bitnagil.data.user.service

import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto
import com.threegap.bitnagil.network.model.BaseResponse
import retrofit2.http.GET

interface UserService {
@GET("/api/v1/users/nickname")
suspend fun fetchUserProfile(): BaseResponse<UserProfileResponseDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.threegap.bitnagil.domain.emotion.model

data class MyEmotion(
val emotionMarbleType: Emotion?,
val emotionMarbleName: String?,
val imageUrl: String?,
)
Loading