更新代码
This commit is contained in:
@@ -10,6 +10,7 @@ import com.aiosman.riderpro.data.api.UpdateNoticeRequestBody
|
||||
import com.aiosman.riderpro.entity.AccountFavouriteEntity
|
||||
import com.aiosman.riderpro.entity.AccountLikeEntity
|
||||
import com.aiosman.riderpro.entity.AccountProfileEntity
|
||||
import com.aiosman.riderpro.entity.NoticeCommentEntity
|
||||
import com.aiosman.riderpro.entity.NoticePostEntity
|
||||
import com.aiosman.riderpro.entity.NoticeUserEntity
|
||||
import com.google.gson.annotations.SerializedName
|
||||
@@ -102,6 +103,34 @@ data class NoticePost(
|
||||
}
|
||||
}
|
||||
|
||||
//"comment": {
|
||||
// "id": 103,
|
||||
// "content": "ppp",
|
||||
// "time": "2024-09-08 15:31:37"
|
||||
//}
|
||||
data class NoticeComment(
|
||||
@SerializedName("id")
|
||||
val id: Int,
|
||||
@SerializedName("content")
|
||||
val content: String,
|
||||
@SerializedName("time")
|
||||
val time: String,
|
||||
@SerializedName("replyComment")
|
||||
val replyComment: NoticeComment?,
|
||||
@SerializedName("postId")
|
||||
val postId: Int,
|
||||
) {
|
||||
fun toNoticeCommentEntity(): NoticeCommentEntity {
|
||||
return NoticeCommentEntity(
|
||||
id = id,
|
||||
content = content,
|
||||
postId = postId,
|
||||
time = ApiClient.dateFromApiString(time),
|
||||
replyComment = replyComment?.toNoticeCommentEntity()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息关联用户
|
||||
*/
|
||||
@@ -137,19 +166,26 @@ data class AccountLike(
|
||||
val isUnread: Boolean,
|
||||
// 动态
|
||||
@SerializedName("post")
|
||||
val post: NoticePost,
|
||||
val post: NoticePost?,
|
||||
@SerializedName("comment")
|
||||
val comment: NoticeComment?,
|
||||
// 点赞用户
|
||||
@SerializedName("user")
|
||||
val user: NoticeUser,
|
||||
// 点赞时间
|
||||
@SerializedName("likeTime")
|
||||
val likeTime: String,
|
||||
// 动态ID
|
||||
@SerializedName("postId")
|
||||
val postId: Int,
|
||||
) {
|
||||
fun toAccountLikeEntity(): AccountLikeEntity {
|
||||
return AccountLikeEntity(
|
||||
post = post.toNoticePostEntity(),
|
||||
post = post?.toNoticePostEntity(),
|
||||
comment = comment?.toNoticeCommentEntity(),
|
||||
user = user.toNoticeUserEntity(),
|
||||
likeTime = ApiClient.dateFromApiString(likeTime)
|
||||
likeTime = ApiClient.dateFromApiString(likeTime),
|
||||
postId = postId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -302,7 +338,7 @@ interface AccountService {
|
||||
*/
|
||||
suspend fun updateNotice(payload: UpdateNoticeRequestBody)
|
||||
|
||||
suspend fun registerMessageChannel(client:String,identifier:String)
|
||||
suspend fun registerMessageChannel(client: String, identifier: String)
|
||||
}
|
||||
|
||||
class AccountServiceImpl : AccountService {
|
||||
@@ -320,8 +356,13 @@ class AccountServiceImpl : AccountService {
|
||||
|
||||
override suspend fun loginUserWithPassword(loginName: String, password: String): UserAuth {
|
||||
val resp = ApiClient.api.login(LoginUserRequestBody(loginName, password))
|
||||
val body = resp.body() ?: throw ServiceException("Failed to login")
|
||||
return UserAuth(0, body.token)
|
||||
if (!resp.isSuccessful) {
|
||||
parseErrorResponse(resp.errorBody())?.let {
|
||||
throw it.toServiceException()
|
||||
}
|
||||
throw ServiceException("Failed to register")
|
||||
}
|
||||
return UserAuth(0, resp.body()?.token)
|
||||
}
|
||||
|
||||
override suspend fun loginUserWithGoogle(googleId: String): UserAuth {
|
||||
@@ -411,7 +452,7 @@ class AccountServiceImpl : AccountService {
|
||||
}
|
||||
|
||||
override suspend fun registerMessageChannel(client: String, identifier: String) {
|
||||
ApiClient.api.registerMessageChannel(RegisterMessageChannelRequestBody(client,identifier))
|
||||
ApiClient.api.registerMessageChannel(RegisterMessageChannelRequestBody(client, identifier))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user