更新个人资料编辑功能

- 新增主页背景图编辑
- 优化个人资料编辑页面布局
This commit is contained in:
2024-08-28 16:40:09 +08:00
parent 07b89fe3cc
commit 65e348e704
11 changed files with 232 additions and 103 deletions

View File

@@ -36,7 +36,11 @@ data class AccountProfile(
// 粉丝数
val followerCount: Int,
// 是否关注
val isFollowing: Boolean
val isFollowing: Boolean,
// 个人简介
val bio: String,
// 主页背景图
val banner: String?,
) {
/**
* 转换为Entity
@@ -48,9 +52,10 @@ data class AccountProfile(
followingCount = followingCount,
nickName = nickname,
avatar = "${ApiClient.BASE_SERVER}$avatar",
bio = "",
bio = bio,
country = "Worldwide",
isFollowing = isFollowing
isFollowing = isFollowing,
banner = "${ApiClient.BASE_SERVER}$banner"
)
}
}
@@ -230,8 +235,14 @@ interface AccountService {
* @param avatar 头像
* @param nickName 昵称
* @param bio 简介
* @param banner 主页背景图
*/
suspend fun updateProfile(avatar: UploadImage?, nickName: String?, bio: String?)
suspend fun updateProfile(
avatar: UploadImage?,
banner: UploadImage?,
nickName: String?,
bio: String?
)
/**
* 注册用户
@@ -328,12 +339,21 @@ class AccountServiceImpl : AccountService {
return MultipartBody.Part.createFormData(name, filename, requestFile)
}
override suspend fun updateProfile(avatar: UploadImage?, nickName: String?, bio: String?) {
override suspend fun updateProfile(
avatar: UploadImage?,
banner: UploadImage?,
nickName: String?,
bio: String?
) {
val nicknameField: RequestBody? = nickName?.toRequestBody("text/plain".toMediaTypeOrNull())
val bioField: RequestBody? = bio?.toRequestBody("text/plain".toMediaTypeOrNull())
val avatarField: MultipartBody.Part? = avatar?.let {
createMultipartBody(it.file, it.filename, "avatar")
}
ApiClient.api.updateProfile(avatarField, nicknameField)
val bannerField: MultipartBody.Part? = banner?.let {
createMultipartBody(it.file, it.filename, "banner")
}
ApiClient.api.updateProfile(avatarField, bannerField, nicknameField, bioField)
}
override suspend fun registerUserWithPassword(loginName: String, password: String) {

View File

@@ -169,7 +169,9 @@ interface RiderProAPI {
@PATCH("account/my/profile")
suspend fun updateProfile(
@Part avatar: MultipartBody.Part?,
@Part banner: MultipartBody.Part?,
@Part("nickname") nickname: RequestBody?,
@Part("bio") bio: RequestBody?,
): Response<Unit>
@POST("account/my/password")