Files
rider-pro-android-app/app/src/main/java/com/aiosman/riderpro/data/UserService.kt

39 lines
987 B
Kotlin
Raw Normal View History

2024-07-29 00:01:09 +08:00
package com.aiosman.riderpro.data
import com.aiosman.riderpro.test.TestDatabase
2024-07-30 16:57:25 +08:00
data class UserAuth(
val id: Int,
val token: String? = null
)
2024-07-29 00:01:09 +08:00
interface UserService {
2024-07-30 16:57:25 +08:00
suspend fun getUserProfile(id: String): AccountProfile
suspend fun getMyAccount(): UserAuth
suspend fun loginUserWithPassword(loginName: String, password: String): UserAuth
suspend fun logout()
2024-07-29 00:01:09 +08:00
}
class TestUserServiceImpl : UserService {
override suspend fun getUserProfile(id: String): AccountProfile {
TestDatabase.accountData.forEach {
if (it.id == id.toInt()) {
return it
}
}
return AccountProfile(0, 0, 0, "", "", "", "")
}
2024-07-30 16:57:25 +08:00
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
}
2024-07-29 00:01:09 +08:00
}