Introduce travel album entry with Sony PTP tethering pipeline, profile space settings page, home routing updates, Launch Screen storyboard, and related tests/docs. Co-authored-by: Cursor <cursoragent@cursor.com>
137 lines
4.3 KiB
Swift
137 lines
4.3 KiB
Swift
//
|
||
// ProfileAPI.swift
|
||
// suixinkan
|
||
//
|
||
// Created by Codex on 2026/6/20.
|
||
//
|
||
|
||
import Foundation
|
||
import Combine
|
||
|
||
@MainActor
|
||
/// 个人空间配置 API 协议,便于页面 ViewModel 使用测试替身。
|
||
protocol ProfileSpaceServing {
|
||
/// 拉取当前景区下的个人空间配置。
|
||
func profileSpaceInfo(scenicId: Int) async throws -> ProfileSpaceInfoResponse
|
||
|
||
/// 更新当前景区下的个人空间配置。
|
||
func updateProfileSpaceInfo(_ request: UpdateProfileSpaceRequest) async throws
|
||
|
||
/// 更新用户昵称、密码或头像地址。
|
||
func updateUserInfo(nickname: String?, password: String?, avatar: String?) async throws
|
||
|
||
/// 单独更新用户头像 URL。
|
||
func updateUserAvatarURL(_ fileURL: String) async throws
|
||
}
|
||
|
||
@MainActor
|
||
/// 个人信息 API,封装“我的”页面需要的用户资料和资料更新接口。
|
||
final class ProfileAPI {
|
||
private let client: APIClient
|
||
|
||
/// 初始化个人信息 API,并注入共享网络客户端。
|
||
init(client: APIClient) {
|
||
self.client = client
|
||
}
|
||
|
||
/// 拉取当前登录用户的基础资料。
|
||
func userInfo() async throws -> UserInfoResponse {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/yf-handset-app/userinfo"
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 拉取当前登录账号可切换的景区账号和门店账号。
|
||
func switchableAccounts() async throws -> V9AuthResponse {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/app/v9/accounts"
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 拉取当前登录用户的实名认证状态。
|
||
func realNameInfo() async throws -> RealNameInfoResponse {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/yf-handset-app/photog/real-name/info"
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 更新用户昵称、密码或头像地址。
|
||
func updateUserInfo(nickname: String? = nil, password: String? = nil, avatar: String? = nil) async throws {
|
||
let request = UpdateInfoRequest(nickname: nickname, password: password, avatar: avatar)
|
||
let _: EmptyPayload = try await client.send(
|
||
APIRequest(
|
||
method: .post,
|
||
path: "/api/yf-handset-app/userinfo-update",
|
||
body: request
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 单独更新用户头像 URL,供 OSS 上传完成后回写服务端。
|
||
func updateUserAvatarURL(_ fileURL: String) async throws {
|
||
let _: EmptyPayload = try await client.send(
|
||
APIRequest(
|
||
method: .post,
|
||
path: "/api/yf-handset-app/userinfo-update-avatar-url",
|
||
queryItems: [URLQueryItem(name: "file_url", value: fileURL)]
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 拉取当前景区下的个人空间配置。
|
||
func profileSpaceInfo(scenicId: Int) async throws -> ProfileSpaceInfoResponse {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/yf-handset-app/photog/profile/info",
|
||
queryItems: [URLQueryItem(name: "scenic_id", value: "\(scenicId)")]
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 更新当前景区下的个人空间配置。
|
||
func updateProfileSpaceInfo(_ request: UpdateProfileSpaceRequest) async throws {
|
||
let _: EmptyPayload = try await client.send(
|
||
APIRequest(
|
||
method: .post,
|
||
path: "/api/yf-handset-app/photog/profile/info-update",
|
||
body: request
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 发送实名认证短信验证码。
|
||
func realNameSmsVerifyCode() async throws {
|
||
let _: EmptyPayload = try await client.send(
|
||
APIRequest(
|
||
method: .post,
|
||
path: "/api/yf-handset-app/photog/real-name/sms-verify-code",
|
||
body: EmptyPayload()
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 提交实名认证资料。
|
||
func realNameSubmit(_ request: RealNameAuthRequest) async throws {
|
||
let _: EmptyPayload = try await client.send(
|
||
APIRequest(
|
||
method: .post,
|
||
path: "/api/yf-handset-app/photog/real-name/submit",
|
||
body: request
|
||
)
|
||
)
|
||
}
|
||
}
|
||
|
||
extension ProfileAPI: UserProfileServing {}
|
||
extension ProfileAPI: ProfileSpaceServing {}
|