Skip to content

Commit da4e368

Browse files
authored
Merge pull request #55 from YAPP-Github/feature/#52-home-api
2 parents 5b111d8 + b2b1a76 commit da4e368

File tree

47 files changed

+441
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+441
-4
lines changed

app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import com.threegap.bitnagil.data.recommendroutine.datasource.RecommendRoutineDa
1212
import com.threegap.bitnagil.data.recommendroutine.datasourceImpl.RecommendRoutineDataSourceImpl
1313
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
1414
import com.threegap.bitnagil.data.routine.datasourceImpl.RoutineRemoteDataSourceImpl
15+
import com.threegap.bitnagil.data.user.datasource.UserDataSource
16+
import com.threegap.bitnagil.data.user.datasourceImpl.UserDataSourceImpl
1517
import com.threegap.bitnagil.data.writeroutine.datasource.WriteRoutineDataSource
1618
import com.threegap.bitnagil.data.writeroutine.datasourceImpl.WriteRoutineDataSourceImpl
1719
import dagger.Binds
@@ -48,6 +50,10 @@ abstract class DataSourceModule {
4850
@Singleton
4951
abstract fun bindWriteRoutineDataSource(writeRoutineDataSourceImpl: WriteRoutineDataSourceImpl): WriteRoutineDataSource
5052

53+
@Binds
54+
@Singleton
55+
abstract fun bindUserDataSource(userDataSourceImpl: UserDataSourceImpl): UserDataSource
56+
5157
@Binds
5258
@Singleton
5359
abstract fun bindRecommendRoutineDataSource(recommendRoutineDataSourceImpl: RecommendRoutineDataSourceImpl): RecommendRoutineDataSource

app/src/main/java/com/threegap/bitnagil/di/data/RepositoryModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import com.threegap.bitnagil.data.emotion.repositoryImpl.EmotionRepositoryImpl
55
import com.threegap.bitnagil.data.onboarding.repositoryImpl.OnBoardingRepositoryImpl
66
import com.threegap.bitnagil.data.recommendroutine.repositoryImpl.RecommendRoutineRepositoryImpl
77
import com.threegap.bitnagil.data.routine.repositoryImpl.RoutineRepositoryImpl
8+
import com.threegap.bitnagil.data.user.repositoryImpl.UserRepositoryImpl
89
import com.threegap.bitnagil.data.writeroutine.repositoryImpl.WriteRoutineRepositoryImpl
910
import com.threegap.bitnagil.domain.auth.repository.AuthRepository
1011
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
1112
import com.threegap.bitnagil.domain.onboarding.repository.OnBoardingRepository
1213
import com.threegap.bitnagil.domain.recommendroutine.repository.RecommendRoutineRepository
1314
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
15+
import com.threegap.bitnagil.domain.user.repository.UserRepository
1416
import com.threegap.bitnagil.domain.writeroutine.repository.WriteRoutineRepository
1517
import dagger.Binds
1618
import dagger.Module
@@ -42,6 +44,10 @@ abstract class RepositoryModule {
4244
@Singleton
4345
abstract fun bindWriteRoutineRepository(writeRoutineRepositoryImpl: WriteRoutineRepositoryImpl): WriteRoutineRepository
4446

47+
@Binds
48+
@Singleton
49+
abstract fun bindUserRepository(userRepositoryImpl: UserRepositoryImpl): UserRepository
50+
4551
@Binds
4652
@Singleton
4753
abstract fun bindRecommendRoutineRepository(recommendRoutineRepositoryImpl: RecommendRoutineRepositoryImpl): RecommendRoutineRepository

app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.threegap.bitnagil.data.emotion.service.EmotionService
55
import com.threegap.bitnagil.data.onboarding.service.OnBoardingService
66
import com.threegap.bitnagil.data.recommendroutine.service.RecommendRoutineService
77
import com.threegap.bitnagil.data.routine.service.RoutineService
8+
import com.threegap.bitnagil.data.user.service.UserService
89
import com.threegap.bitnagil.data.writeroutine.service.WriteRoutineService
910
import com.threegap.bitnagil.di.core.Auth
1011
import com.threegap.bitnagil.di.core.NoneAuth
@@ -50,6 +51,11 @@ object ServiceModule {
5051
fun provideReissueService(@NoneAuth retrofit: Retrofit): ReissueService =
5152
retrofit.create(ReissueService::class.java)
5253

54+
@Provides
55+
@Singleton
56+
fun provideUserService(@Auth retrofit: Retrofit): UserService =
57+
retrofit.create(UserService::class.java)
58+
5359
@Provides
5460
@Singleton
5561
fun provideRecommendRoutineService(@Auth retrofit: Retrofit): RecommendRoutineService =

core/network/src/main/java/com/threegap/bitnagil/network/model/AuthToken.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ data class AuthToken(
99
val accessToken: String,
1010
@SerialName("refreshToken")
1111
val refreshToken: String,
12-
@SerialName("role") // todo: 제거 예정
13-
val role: String,
1412
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.threegap.bitnagil.data.emotion.datasource
22

33
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
4+
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
45
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
56

67
interface EmotionDataSource {
78
suspend fun getEmotions(): Result<GetEmotionsResponse>
89
suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse>
10+
suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotionResponseDto>
911
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
55
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
66
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
7+
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
78
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
89
import com.threegap.bitnagil.data.emotion.service.EmotionService
910
import javax.inject.Inject
@@ -23,4 +24,9 @@ class EmotionDataSourceImpl @Inject constructor(
2324
emotionService.postEmotions(registerEmotionRequest)
2425
}
2526
}
27+
28+
override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotionResponseDto> =
29+
safeApiCall {
30+
emotionService.getMyEmotionMarble(currentDate)
31+
}
2632
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.threegap.bitnagil.data.emotion.model.response
2+
3+
import com.threegap.bitnagil.domain.emotion.model.Emotion
4+
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
5+
import kotlinx.serialization.SerialName
6+
import kotlinx.serialization.Serializable
7+
8+
@Serializable
9+
data class MyEmotionResponseDto(
10+
@SerialName("emotionMarbleType")
11+
val emotionMarbleType: String?,
12+
@SerialName("emotionMarbleName")
13+
val emotionMarbleName: String?,
14+
@SerialName("imageUrl")
15+
val imageUrl: String?,
16+
)
17+
18+
fun MyEmotionResponseDto.toDomain(): MyEmotion =
19+
MyEmotion(
20+
emotionMarbleType = emotionMarbleType?.let { Emotion.valueOf(it) },
21+
emotionMarbleName = emotionMarbleName,
22+
imageUrl = imageUrl,
23+
)

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

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

33
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
4+
import com.threegap.bitnagil.data.emotion.model.response.toDomain
45
import com.threegap.bitnagil.domain.emotion.model.Emotion
6+
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
57
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
68
import javax.inject.Inject
79

@@ -36,4 +38,7 @@ class EmotionRepositoryImpl @Inject constructor(
3638

3739
return emotionDataSource.registerEmotion(selectedEmotion).map { _ -> }
3840
}
41+
42+
override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion> =
43+
emotionDataSource.getMyEmotionMarble(currentDate).map { it.toDomain() }
3944
}

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

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

33
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
44
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
5+
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
56
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
67
import com.threegap.bitnagil.network.model.BaseResponse
78
import retrofit2.http.Body
89
import retrofit2.http.GET
910
import retrofit2.http.POST
11+
import retrofit2.http.Query
1012

1113
interface EmotionService {
1214
@GET("/api/v1/emotion-marbles")
@@ -16,4 +18,9 @@ interface EmotionService {
1618
suspend fun postEmotions(
1719
@Body request: RegisterEmotionRequest,
1820
): BaseResponse<RegisterEmotionResponse>
21+
22+
@GET("/api/v1/emotion-marbles/me")
23+
suspend fun getMyEmotionMarble(
24+
@Query("searchDate") date: String,
25+
): BaseResponse<MyEmotionResponseDto>
1926
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.threegap.bitnagil.data.routine.datasource
22

3+
import com.threegap.bitnagil.data.routine.model.request.RoutineByDayDeletionRequestDto
34
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
45
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
56

67
interface RoutineRemoteDataSource {
78
suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result<RoutinesResponseDto>
89
suspend fun syncRoutineCompletion(routineCompletionRequestDto: RoutineCompletionRequestDto): Result<Unit>
910
suspend fun deleteRoutine(routineId: String): Result<Unit>
11+
suspend fun deleteRoutineByDay(routineByDayDeletionRequestDto: RoutineByDayDeletionRequestDto): Result<Unit>
1012
}

0 commit comments

Comments
 (0)