更改推送

This commit is contained in:
2024-09-20 17:10:54 +08:00
parent 93182c3985
commit 054dd68b89
20 changed files with 390 additions and 138 deletions

View File

@@ -8,6 +8,7 @@ import com.aiosman.riderpro.data.api.RegisterMessageChannelRequestBody
import com.aiosman.riderpro.data.api.RegisterRequestBody
import com.aiosman.riderpro.data.api.ResetPasswordRequestBody
import com.aiosman.riderpro.data.api.UpdateNoticeRequestBody
import com.aiosman.riderpro.data.api.UpdateUserLangRequestBody
import com.aiosman.riderpro.entity.AccountFavouriteEntity
import com.aiosman.riderpro.entity.AccountLikeEntity
import com.aiosman.riderpro.entity.AccountProfileEntity
@@ -339,10 +340,20 @@ interface AccountService {
*/
suspend fun updateNotice(payload: UpdateNoticeRequestBody)
/**
* 注册消息通道
*/
suspend fun registerMessageChannel(client: String, identifier: String)
/**
* 重置密码
*/
suspend fun resetPassword(email: String)
/**
* 更新用户语言
*/
suspend fun updateUserLanguage(language: String)
}
class AccountServiceImpl : AccountService {
@@ -473,4 +484,8 @@ class AccountServiceImpl : AccountService {
}
}
override suspend fun updateUserLanguage(language: String) {
ApiClient.api.updateUserLang(UpdateUserLangRequestBody(language))
}
}

View File

@@ -68,6 +68,13 @@ interface CommentService {
* @param commentId 评论ID
*/
suspend fun DeleteComment(commentId: Int)
/**
* 获取评论
* @param commentId 评论ID
*/
suspend fun getCommentById(commentId: Int): CommentEntity
}
/**
@@ -120,7 +127,6 @@ data class Comment(
comment = content,
date = ApiClient.dateFromApiString(createdAt),
likes = likeCount,
replies = emptyList(),
postId = postId,
avatar = "${ApiClient.BASE_SERVER}${user.avatar}",
author = user.id,
@@ -240,4 +246,10 @@ class CommentServiceImpl : CommentService {
val resp = ApiClient.api.deleteComment(commentId)
return
}
override suspend fun getCommentById(commentId: Int): CommentEntity {
val resp = ApiClient.api.getComment(commentId)
val body = resp.body() ?: throw ServiceException("Failed to get comment")
return body.data.toCommentEntity()
}
}

View File

@@ -98,6 +98,11 @@ data class ResetPasswordRequestBody(
val username: String,
)
data class UpdateUserLangRequestBody(
@SerializedName("language")
val lang: String,
)
interface RiderProAPI {
@POST("register")
suspend fun register(@Body body: RegisterRequestBody): Response<Unit>
@@ -280,4 +285,15 @@ interface RiderProAPI {
suspend fun resetPassword(
@Body body: ResetPasswordRequestBody
): Response<Unit>
@GET("comment/{id}")
suspend fun getComment(
@Path("id") id: Int
): Response<DataContainer<Comment>>
@PATCH("account/my/lang")
suspend fun updateUserLang(
@Body body: UpdateUserLangRequestBody
): Response<Unit>
}