Skip to content

Commit 4808be9

Browse files
committed
Feat: 사용자 프로필 정보 조회 기능 추가
- 사용자 프로필 정보 조회 API 연동 - 홈 화면에 사용자 닉네임 표시 - 관련 DataSource, Repository, UseCase, DTO, DI 모듈 추가
1 parent 341a1eb commit 4808be9

File tree

15 files changed

+131
-1
lines changed

15 files changed

+131
-1
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
@@ -10,6 +10,8 @@ import com.threegap.bitnagil.data.onboarding.datasource.OnBoardingDataSource
1010
import com.threegap.bitnagil.data.onboarding.datasourceImpl.OnBoardingDataSourceImpl
1111
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
1212
import com.threegap.bitnagil.data.routine.datasourceImpl.RoutineRemoteDataSourceImpl
13+
import com.threegap.bitnagil.data.user.datasource.UserDataSource
14+
import com.threegap.bitnagil.data.user.datasourceImpl.UserDataSourceImpl
1315
import com.threegap.bitnagil.data.writeroutine.datasource.WriteRoutineDataSource
1416
import com.threegap.bitnagil.data.writeroutine.datasourceImpl.WriteRoutineDataSourceImpl
1517
import dagger.Binds
@@ -45,4 +47,8 @@ abstract class DataSourceModule {
4547
@Binds
4648
@Singleton
4749
abstract fun bindWriteRoutineDataSource(writeRoutineDataSourceImpl: WriteRoutineDataSourceImpl): WriteRoutineDataSource
50+
51+
@Binds
52+
@Singleton
53+
abstract fun bindUserDataSource(userDataSourceImpl: UserDataSourceImpl): UserDataSource
4854
}

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
@@ -4,11 +4,13 @@ import com.threegap.bitnagil.data.auth.repositoryimpl.AuthRepositoryImpl
44
import com.threegap.bitnagil.data.emotion.repositoryImpl.EmotionRepositoryImpl
55
import com.threegap.bitnagil.data.onboarding.repositoryImpl.OnBoardingRepositoryImpl
66
import com.threegap.bitnagil.data.routine.repositoryImpl.RoutineRepositoryImpl
7+
import com.threegap.bitnagil.data.user.repositoryImpl.UserRepositoryImpl
78
import com.threegap.bitnagil.data.writeroutine.repositoryImpl.WriteRoutineRepositoryImpl
89
import com.threegap.bitnagil.domain.auth.repository.AuthRepository
910
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
1011
import com.threegap.bitnagil.domain.onboarding.repository.OnBoardingRepository
1112
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
13+
import com.threegap.bitnagil.domain.user.repository.UserRepository
1214
import com.threegap.bitnagil.domain.writeroutine.repository.WriteRoutineRepository
1315
import dagger.Binds
1416
import dagger.Module
@@ -39,4 +41,8 @@ abstract class RepositoryModule {
3941
@Binds
4042
@Singleton
4143
abstract fun bindWriteRoutineRepository(writeRoutineRepositoryImpl: WriteRoutineRepositoryImpl): WriteRoutineRepository
44+
45+
@Binds
46+
@Singleton
47+
abstract fun bindUserRepository(userRepositoryImpl: UserRepositoryImpl): UserRepository
4248
}

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
@@ -4,6 +4,7 @@ import com.threegap.bitnagil.data.auth.service.AuthService
44
import com.threegap.bitnagil.data.emotion.service.EmotionService
55
import com.threegap.bitnagil.data.onboarding.service.OnBoardingService
66
import com.threegap.bitnagil.data.routine.service.RoutineService
7+
import com.threegap.bitnagil.data.user.service.UserService
78
import com.threegap.bitnagil.data.writeroutine.service.WriteRoutineService
89
import com.threegap.bitnagil.di.core.Auth
910
import com.threegap.bitnagil.di.core.NoneAuth
@@ -48,4 +49,9 @@ object ServiceModule {
4849
@Singleton
4950
fun provideReissueService(@NoneAuth retrofit: Retrofit): ReissueService =
5051
retrofit.create(ReissueService::class.java)
52+
53+
@Provides
54+
@Singleton
55+
fun provideUserService(@Auth retrofit: Retrofit): UserService =
56+
retrofit.create(UserService::class.java)
5157
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.threegap.bitnagil.data.user.datasource
2+
3+
import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto
4+
5+
interface UserDataSource {
6+
suspend fun fetchUserProfile(): Result<UserProfileResponseDto>
7+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.threegap.bitnagil.data.user.datasourceImpl
2+
3+
import com.threegap.bitnagil.data.common.safeApiCall
4+
import com.threegap.bitnagil.data.user.datasource.UserDataSource
5+
import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto
6+
import com.threegap.bitnagil.data.user.service.UserService
7+
import javax.inject.Inject
8+
9+
class UserDataSourceImpl @Inject constructor(
10+
private val userService: UserService,
11+
) : UserDataSource {
12+
override suspend fun fetchUserProfile(): Result<UserProfileResponseDto> =
13+
safeApiCall {
14+
userService.fetchUserProfile()
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.threegap.bitnagil.data.user.model.response
2+
3+
import com.threegap.bitnagil.domain.user.model.UserProfile
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
7+
@Serializable
8+
data class UserProfileResponseDto(
9+
@SerialName("nickname")
10+
val nickname: String,
11+
)
12+
13+
fun UserProfileResponseDto.toDomain() =
14+
UserProfile(
15+
nickname = this.nickname,
16+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.threegap.bitnagil.data.user.repositoryImpl
2+
3+
import com.threegap.bitnagil.data.user.datasource.UserDataSource
4+
import com.threegap.bitnagil.data.user.model.response.toDomain
5+
import com.threegap.bitnagil.domain.user.model.UserProfile
6+
import com.threegap.bitnagil.domain.user.repository.UserRepository
7+
import javax.inject.Inject
8+
9+
class UserRepositoryImpl @Inject constructor(
10+
private val userDataSource: UserDataSource,
11+
) : UserRepository {
12+
override suspend fun fetchUserProfile(): Result<UserProfile> =
13+
userDataSource.fetchUserProfile().map { it.toDomain() }
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.threegap.bitnagil.data.user.service
2+
3+
import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto
4+
import com.threegap.bitnagil.network.model.BaseResponse
5+
import retrofit2.http.GET
6+
7+
interface UserService {
8+
@GET("/api/v1/users/nickname")
9+
suspend fun fetchUserProfile(): BaseResponse<UserProfileResponseDto>
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.threegap.bitnagil.domain.user.model
2+
3+
data class UserProfile(
4+
val nickname: String,
5+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.threegap.bitnagil.domain.user.repository
2+
3+
import com.threegap.bitnagil.domain.user.model.UserProfile
4+
5+
interface UserRepository {
6+
suspend fun fetchUserProfile(): Result<UserProfile>
7+
}

0 commit comments

Comments
 (0)