更新
This commit is contained in:
@@ -15,14 +15,50 @@ data class AccountProfile(
|
||||
interface AccountService {
|
||||
suspend fun getMyAccountProfile(): AccountProfile
|
||||
suspend fun getAccountProfileById(id: Int): AccountProfile
|
||||
suspend fun getMyAccount(): UserAuth
|
||||
suspend fun loginUserWithPassword(loginName: String, password: String): UserAuth
|
||||
suspend fun logout()
|
||||
suspend fun updateAvatar(uri: String)
|
||||
suspend fun updateProfile(nickName: String, bio: String)
|
||||
}
|
||||
|
||||
class TestAccountServiceImpl : AccountService {
|
||||
override suspend fun getMyAccountProfile(): AccountProfile {
|
||||
return TestDatabase.accountData.first { it.id == 0 }
|
||||
return TestDatabase.accountData.first { it.id == 1 }
|
||||
}
|
||||
|
||||
override suspend fun getAccountProfileById(id: Int): AccountProfile {
|
||||
return TestDatabase.accountData.first { it.id == id }
|
||||
}
|
||||
|
||||
override suspend fun getMyAccount(): UserAuth {
|
||||
return UserAuth(1)
|
||||
}
|
||||
|
||||
override suspend fun loginUserWithPassword(loginName: String, password: String): UserAuth {
|
||||
return UserAuth(1, "token")
|
||||
}
|
||||
|
||||
override suspend fun logout() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override suspend fun updateAvatar(uri: String) {
|
||||
TestDatabase.accountData = TestDatabase.accountData.map {
|
||||
if (it.id == 1) {
|
||||
it.copy(avatar = uri)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
}
|
||||
override suspend fun updateProfile(nickName: String, bio: String) {
|
||||
TestDatabase.accountData = TestDatabase.accountData.map {
|
||||
if (it.id == 1) {
|
||||
it.copy(nickName = nickName, bio = bio)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user