更新
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,8 @@ interface MomentService {
|
||||
suspend fun createMoment(
|
||||
content: String,
|
||||
authorId: Int,
|
||||
imageUriList: List<String>
|
||||
imageUriList: List<String>,
|
||||
relPostId: Int? = null
|
||||
): MomentItem
|
||||
}
|
||||
|
||||
@@ -96,9 +97,10 @@ class TestMomentServiceImpl() : MomentService {
|
||||
override suspend fun createMoment(
|
||||
content: String,
|
||||
authorId: Int,
|
||||
imageUriList: List<String>
|
||||
imageUriList: List<String>,
|
||||
relPostId: Int?
|
||||
): MomentItem {
|
||||
return testMomentBackend.createMoment(content, authorId, imageUriList)
|
||||
return testMomentBackend.createMoment(content, authorId, imageUriList, relPostId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,6 +142,9 @@ class TestMomentBackend(
|
||||
if (myLikeIdList.contains(it.id)) {
|
||||
it.liked = true
|
||||
}
|
||||
if (it.relPostId != null) {
|
||||
it.relMoment = rawList.first { it1 -> it1.id == it.relPostId }
|
||||
}
|
||||
}
|
||||
|
||||
// delay
|
||||
@@ -186,7 +191,8 @@ class TestMomentBackend(
|
||||
suspend fun createMoment(
|
||||
content: String,
|
||||
authorId: Int,
|
||||
imageUriList: List<String>
|
||||
imageUriList: List<String>,
|
||||
relPostId: Int?
|
||||
): MomentItem {
|
||||
TestDatabase.momentIdCounter += 1
|
||||
val person = TestDatabase.accountData.first {
|
||||
@@ -206,7 +212,8 @@ class TestMomentBackend(
|
||||
shareCount = 0,
|
||||
favoriteCount = 0,
|
||||
images = imageUriList,
|
||||
authorId = person.id
|
||||
authorId = person.id,
|
||||
relPostId = relPostId
|
||||
)
|
||||
TestDatabase.momentData += newMoment
|
||||
return newMoment
|
||||
|
||||
@@ -9,9 +9,7 @@ data class UserAuth(
|
||||
|
||||
interface UserService {
|
||||
suspend fun getUserProfile(id: String): AccountProfile
|
||||
suspend fun getMyAccount(): UserAuth
|
||||
suspend fun loginUserWithPassword(loginName: String, password: String): UserAuth
|
||||
suspend fun logout()
|
||||
|
||||
}
|
||||
|
||||
class TestUserServiceImpl : UserService {
|
||||
@@ -23,17 +21,4 @@ class TestUserServiceImpl : UserService {
|
||||
}
|
||||
return AccountProfile(0, 0, 0, "", "", "", "")
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user