-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
334 additions
and
24 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
|
@@ -50,4 +50,9 @@ class AppDataStoreImpl( | |
} | ||
} | ||
} | ||
|
||
override suspend fun clear() { | ||
setUuid("") | ||
setToken("") | ||
} | ||
} |
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
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
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
7 changes: 7 additions & 0 deletions
7
core/user/src/main/java/com/stslex/aproselection/core/user/data/model/UserData.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,7 @@ | ||
package com.stslex.aproselection.core.user.data.model | ||
|
||
data class UserData( | ||
val uuid: String, | ||
val username: String, | ||
val nickname: String | ||
) |
16 changes: 16 additions & 0 deletions
16
core/user/src/main/java/com/stslex/aproselection/core/user/data/model/UserMapper.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.stslex.aproselection.core.user.data.model | ||
|
||
import com.stslex.aproselection.core.network.clients.user.model.UpdateUserInfoBody | ||
import com.stslex.aproselection.core.network.clients.user.model.UserResponse | ||
|
||
fun List<UserResponse>.toData() = map { user -> | ||
user.toData() | ||
} | ||
|
||
fun UserResponse.toData() = UserData( | ||
uuid = uuid, | ||
username = username, | ||
nickname = nickname | ||
) | ||
|
||
fun UserUpdateData.toBody() = UpdateUserInfoBody(nickname) |
5 changes: 5 additions & 0 deletions
5
core/user/src/main/java/com/stslex/aproselection/core/user/data/model/UserUpdateData.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,5 @@ | ||
package com.stslex.aproselection.core.user.data.model | ||
|
||
data class UserUpdateData( | ||
val nickname: String | ||
) |
14 changes: 14 additions & 0 deletions
14
core/user/src/main/java/com/stslex/aproselection/core/user/data/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,14 @@ | ||
package com.stslex.aproselection.core.user.data.repository | ||
|
||
import com.stslex.aproselection.core.network.clients.user.model.UpdateUserInfoBody | ||
import com.stslex.aproselection.core.user.data.model.UserData | ||
import com.stslex.aproselection.core.user.data.model.UserUpdateData | ||
|
||
interface UserRepository { | ||
|
||
suspend fun getUserList(page: Int, pageSize: Int): List<UserData> | ||
|
||
suspend fun getUser(uuid: String): UserData | ||
|
||
suspend fun updateUserInfo(info: UserUpdateData): UserData | ||
} |
29 changes: 29 additions & 0 deletions
29
...er/src/main/java/com/stslex/aproselection/core/user/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,29 @@ | ||
package com.stslex.aproselection.core.user.data.repository | ||
|
||
import com.stslex.aproselection.core.network.clients.user.UserNetworkClient | ||
import com.stslex.aproselection.core.user.data.model.UserData | ||
import com.stslex.aproselection.core.user.data.model.UserUpdateData | ||
import com.stslex.aproselection.core.user.data.model.toBody | ||
import com.stslex.aproselection.core.user.data.model.toData | ||
|
||
class UserRepositoryImpl( | ||
private val networkClient: UserNetworkClient | ||
) : UserRepository { | ||
|
||
override suspend fun getUserList( | ||
page: Int, | ||
pageSize: Int | ||
): List<UserData> = networkClient | ||
.getUserList( | ||
page = page, | ||
pageSize = pageSize | ||
).toData() | ||
|
||
override suspend fun getUser( | ||
uuid: String | ||
): UserData = networkClient.getUser(uuid).toData() | ||
|
||
override suspend fun updateUserInfo( | ||
info: UserUpdateData | ||
): UserData = networkClient.updateUserInfo(info.toBody()).toData() | ||
} |
11 changes: 11 additions & 0 deletions
11
core/user/src/main/java/com/stslex/aproselection/core/user/di/ModuleCoreUser.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,11 @@ | ||
package com.stslex.aproselection.core.user.di | ||
|
||
import com.stslex.aproselection.core.user.data.repository.UserRepository | ||
import com.stslex.aproselection.core.user.data.repository.UserRepositoryImpl | ||
import org.koin.core.module.dsl.bind | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.module | ||
|
||
val moduleCoreUser = module { | ||
singleOf(::UserRepositoryImpl) { bind<UserRepository>() } | ||
} |
5 changes: 5 additions & 0 deletions
5
feature/home/src/main/java/com/stslex/aproselection/feature/home/di/ModuleFeatureHome.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,9 +1,14 @@ | ||
package com.stslex.aproselection.feature.home.di | ||
|
||
import com.stslex.aproselection.feature.home.domain.HomeInteractor | ||
import com.stslex.aproselection.feature.home.domain.HomeInteractorImpl | ||
import com.stslex.aproselection.feature.home.ui.HomeViewModel | ||
import org.koin.androidx.viewmodel.dsl.viewModelOf | ||
import org.koin.core.module.dsl.bind | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.module | ||
|
||
val moduleFeatureHome = module { | ||
viewModelOf(::HomeViewModel) | ||
singleOf(::HomeInteractorImpl) { bind<HomeInteractor>() } | ||
} |
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
28 changes: 28 additions & 0 deletions
28
...ure/home/src/main/java/com/stslex/aproselection/feature/home/domain/HomeInteractorImpl.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,28 @@ | ||
package com.stslex.aproselection.feature.home.domain | ||
|
||
import com.stslex.aproselection.core.datastore.AppDataStore | ||
import com.stslex.aproselection.core.user.data.repository.UserRepository | ||
import com.stslex.aproselection.feature.home.domain.model.UserDomain | ||
import com.stslex.aproselection.feature.home.domain.model.toDomain | ||
|
||
class HomeInteractorImpl( | ||
private val repository: UserRepository, | ||
private val appDataStore: AppDataStore, | ||
) : HomeInteractor { | ||
|
||
override suspend fun getAllUsers( | ||
page: Int, | ||
pageSize: Int | ||
): List<UserDomain> = repository | ||
.getUserList( | ||
page = page, | ||
pageSize = pageSize | ||
) | ||
.map { user -> | ||
user.toDomain() | ||
} | ||
|
||
override suspend fun logOut() { | ||
appDataStore.clear() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
feature/home/src/main/java/com/stslex/aproselection/feature/home/domain/model/HomeMapper.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,9 @@ | ||
package com.stslex.aproselection.feature.home.domain.model | ||
|
||
import com.stslex.aproselection.core.user.data.model.UserData | ||
|
||
fun UserData.toDomain() = UserDomain( | ||
uuid = uuid, | ||
username = username, | ||
nickname = nickname | ||
) |
Oops, something went wrong.