-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] Remote Local 레포지토리 통합 및 데이터 소스 분리
- Loading branch information
1 parent
9d4dd96
commit f99abfd
Showing
18 changed files
with
140 additions
and
98 deletions.
There are no files selected for viewing
12 changes: 8 additions & 4 deletions
12
...ain/repository/UserDataStoreRepository.kt → ...tasource/local/api/UserLocalDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package com.mashup.dorabangs.domain.repository | ||
package com.mashup.dorabangs.data.datasource.local.api | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface UserDataStoreRepository { | ||
interface UserLocalDataSource { | ||
|
||
suspend fun setUserAccessToken(accessToken: String) | ||
fun getUserAccessToken(): Flow<String> | ||
|
||
suspend fun setIsFirstEntry(isFirst: Boolean) | ||
|
||
fun getUserAccessToken(): Flow<String> | ||
|
||
fun getIsFirstEntry(): Flow<Boolean> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
data/src/main/kotlin/com/mashup/dorabangs/data/datasource/remote/api/UserRemoteDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mashup.dorabangs.data.datasource.remote.api | ||
|
||
import com.mashup.dorabangs.data.model.DeviceTokenDataModel | ||
|
||
interface UserRemoteDataSource { | ||
|
||
suspend fun registerUser(deviceToken: DeviceTokenDataModel): String | ||
} |
16 changes: 16 additions & 0 deletions
16
.../main/kotlin/com/mashup/dorabangs/data/datasource/remote/impl/UserRemoteDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.mashup.dorabangs.data.datasource.remote.impl | ||
|
||
import com.mashup.dorabangs.data.datasource.remote.api.UserRemoteDataSource | ||
import com.mashup.dorabangs.data.model.DeviceTokenDataModel | ||
import com.mashup.dorabangs.data.network.service.UserService | ||
import javax.inject.Inject | ||
|
||
class UserRemoteDataSourceImpl @Inject constructor( | ||
private val userService: UserService | ||
) : UserRemoteDataSource { | ||
|
||
override suspend fun registerUser(deviceToken: DeviceTokenDataModel): String = | ||
userService.registerUser(deviceToken) | ||
?.data | ||
?.accessToken ?: "" | ||
} |
29 changes: 29 additions & 0 deletions
29
data/src/main/kotlin/com/mashup/dorabangs/data/di/DataSourceModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mashup.dorabangs.data.di | ||
|
||
import com.mashup.dorabangs.data.datasource.local.api.UserLocalDataSource | ||
import com.mashup.dorabangs.data.datasource.local.impl.UserLocalDataSourceImpl | ||
import com.mashup.dorabangs.data.datasource.remote.api.UserRemoteDataSource | ||
import com.mashup.dorabangs.data.datasource.remote.impl.UserRemoteDataSourceImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Reusable | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class DataSourceModule { | ||
|
||
@Binds | ||
@Reusable | ||
abstract fun bindUserLocalDataSource( | ||
dataSource: UserLocalDataSourceImpl, | ||
): UserLocalDataSource | ||
|
||
@Binds | ||
@Reusable | ||
abstract fun bindUserRemoteDataSource( | ||
dataSource: UserRemoteDataSourceImpl, | ||
): UserRemoteDataSource | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 5 additions & 14 deletions
19
data/src/main/kotlin/com/mashup/dorabangs/data/di/RepositoryModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
package com.mashup.dorabangs.data.di | ||
|
||
import com.mashup.dorabangs.data.repository.UserDataStoreRepositoryImpl | ||
import com.mashup.dorabangs.data.repository.UserRemoteRepositoryImpl | ||
import com.mashup.dorabangs.domain.repository.UserDataStoreRepository | ||
import com.mashup.dorabangs.domain.repository.UserRemoteRepository | ||
import com.mashup.dorabangs.data.repository.UserRepositoryImpl | ||
import com.mashup.dorabangs.domain.repository.UserRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Reusable | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class RepositoryModule { | ||
@Binds | ||
@Reusable | ||
abstract fun bindUserDataStoreRepository( | ||
userDataStoreRepositoryImpl: UserDataStoreRepositoryImpl, | ||
): UserDataStoreRepository | ||
|
||
@Binds | ||
@Reusable | ||
abstract fun bindUserRemoteRepository( | ||
userRemoteRepositoryImpl: UserRemoteRepositoryImpl, | ||
): UserRemoteRepository | ||
abstract fun bindUserRepository( | ||
repositoryImpl: UserRepositoryImpl, | ||
): UserRepository | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
data/src/main/kotlin/com/mashup/dorabangs/data/repository/UserDataStoreRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
data/src/main/kotlin/com/mashup/dorabangs/data/repository/UserRemoteRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
data/src/main/kotlin/com/mashup/dorabangs/data/repository/UserRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.mashup.dorabangs.data.repository | ||
|
||
import com.mashup.dorabangs.data.datasource.local.api.UserLocalDataSource | ||
import com.mashup.dorabangs.data.datasource.remote.api.UserRemoteDataSource | ||
import com.mashup.dorabangs.data.model.asData | ||
import com.mashup.dorabangs.domain.model.DeviceToken | ||
import com.mashup.dorabangs.domain.repository.UserRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class UserRepositoryImpl @Inject constructor( | ||
private val userLocalDataSource: UserLocalDataSource, | ||
private val userRemoteDataSource: UserRemoteDataSource, | ||
) : UserRepository { | ||
override suspend fun setUserAccessToken(accessToken: String) { | ||
userLocalDataSource.setUserAccessToken(accessToken = accessToken) | ||
} | ||
|
||
override fun getUserAccessToken(): Flow<String> { | ||
return userLocalDataSource.getUserAccessToken() | ||
} | ||
|
||
override suspend fun setIsFirstEntry(isFirst: Boolean) { | ||
userLocalDataSource.setIsFirstEntry(isFirst = isFirst) | ||
} | ||
|
||
override fun getIsFirstEntry(): Flow<Boolean> { | ||
return userLocalDataSource.getIsFirstEntry() | ||
} | ||
|
||
override suspend fun registerDeviceToken(deviceToken: DeviceToken): String { | ||
return userRemoteDataSource.registerUser(deviceToken.asData()) | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
domain/src/main/kotlin/com/mashup/dorabangs/domain/repository/UserRemoteRepository.kt
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
domain/src/main/kotlin/com/mashup/dorabangs/domain/repository/UserRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.mashup.dorabangs.domain.repository | ||
|
||
import com.mashup.dorabangs.domain.model.DeviceToken | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface UserRepository { | ||
suspend fun setUserAccessToken(accessToken: String) | ||
fun getUserAccessToken(): Flow<String> | ||
suspend fun setIsFirstEntry(isFirst: Boolean) | ||
fun getIsFirstEntry(): Flow<Boolean> | ||
suspend fun registerDeviceToken(deviceToken: DeviceToken): String | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/kotlin/com/mashup/dorabangs/domain/usecase/user/GetIsFirstEntryUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package com.mashup.dorabangs.domain.usecase.user | ||
|
||
import com.mashup.dorabangs.domain.repository.UserDataStoreRepository | ||
import com.mashup.dorabangs.domain.repository.UserRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetIsFirstEntryUseCase @Inject constructor( | ||
private val userDataStoreRepository: UserDataStoreRepository, | ||
private val userRepository: UserRepository, | ||
) { | ||
operator fun invoke(): Flow<Boolean> { | ||
return userDataStoreRepository.getIsFirstEntry() | ||
return userRepository.getIsFirstEntry() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/kotlin/com/mashup/dorabangs/domain/usecase/user/GetUserAccessTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package com.mashup.dorabangs.domain.usecase.user | ||
|
||
import com.mashup.dorabangs.domain.repository.UserDataStoreRepository | ||
import com.mashup.dorabangs.domain.repository.UserRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetUserAccessTokenUseCase @Inject constructor( | ||
private val userDataStoreRepository: UserDataStoreRepository, | ||
private val userRepository: UserRepository, | ||
) { | ||
operator fun invoke(): Flow<String> { | ||
return userDataStoreRepository.getUserAccessToken() | ||
return userRepository.getUserAccessToken() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/kotlin/com/mashup/dorabangs/domain/usecase/user/RegisterUserUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package com.mashup.dorabangs.domain.usecase.user | ||
|
||
import com.mashup.dorabangs.domain.model.DeviceToken | ||
import com.mashup.dorabangs.domain.repository.UserRemoteRepository | ||
import com.mashup.dorabangs.domain.repository.UserRepository | ||
import javax.inject.Inject | ||
|
||
class RegisterUserUseCase @Inject constructor( | ||
private val userRemoteRepository: UserRemoteRepository, | ||
private val userRepository: UserRepository, | ||
) { | ||
|
||
suspend operator fun invoke(deviceToken: DeviceToken): String { | ||
return userRemoteRepository.registerUser(deviceToken) | ||
return userRepository.registerDeviceToken(deviceToken) | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/kotlin/com/mashup/dorabangs/domain/usecase/user/SetIsFirstEntryUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.mashup.dorabangs.domain.usecase.user | ||
|
||
import com.mashup.dorabangs.domain.repository.UserDataStoreRepository | ||
import com.mashup.dorabangs.domain.repository.UserRepository | ||
import javax.inject.Inject | ||
|
||
class SetIsFirstEntryUseCase @Inject constructor( | ||
private val userDataStoreRepository: UserDataStoreRepository, | ||
private val userRepository: UserRepository, | ||
) { | ||
suspend operator fun invoke(isFirst: Boolean) { | ||
userDataStoreRepository.setIsFirstEntry(isFirst = isFirst) | ||
userRepository.setIsFirstEntry(isFirst = isFirst) | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/kotlin/com/mashup/dorabangs/domain/usecase/user/SetUserAccessTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.mashup.dorabangs.domain.usecase.user | ||
|
||
import com.mashup.dorabangs.domain.repository.UserDataStoreRepository | ||
import com.mashup.dorabangs.domain.repository.UserRepository | ||
import javax.inject.Inject | ||
|
||
class SetUserAccessTokenUseCase @Inject constructor( | ||
private val userDataStoreRepository: UserDataStoreRepository, | ||
private val userRepository: UserRepository, | ||
) { | ||
suspend operator fun invoke(accessToken: String) { | ||
userDataStoreRepository.setUserAccessToken(accessToken = accessToken) | ||
userRepository.setUserAccessToken(accessToken = accessToken) | ||
} | ||
} |