import Foundation /// 用户资料,对齐后端 app/api/v1/user.py(需登录)。 struct UserService { private var api: APIClient { .shared } /// 改昵称,返回更新后的 user。 func updateNickname(_ nickname: String) async throws -> UserDTO { try await api.patch("api/v1/user/profile", body: ProfileUpdateRequest(nickname: nickname)) } /// 上传头像(字段名 file),返回更新后的 user(含新 avatar_url)。 func uploadAvatar(jpeg: Data) async throws -> UserDTO { try await api.postMultipart( "api/v1/user/avatar", files: [MultipartFile(name: "file", filename: "avatar.jpg", mimeType: "image/jpeg", data: jpeg)] ) } /// 注销账号(软删除 + 匿名化)。 func deleteAccount() async throws -> OkResponse { try await api.delete("api/v1/user") } }