Implement task creation with cloud/local media, order linking, and OSS upload; wire home entry and move profile nickname/avatar editing to ProfileEditViewController. Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
2.6 KiB
Swift
82 lines
2.6 KiB
Swift
//
|
||
// TaskAPI.swift
|
||
// suixinkan
|
||
//
|
||
|
||
import Foundation
|
||
|
||
@MainActor
|
||
/// 任务相关 API,封装创建任务、可选订单与云盘列表接口。
|
||
final class TaskAPI {
|
||
private let client: APIClient
|
||
|
||
init(client: APIClient) {
|
||
self.client = client
|
||
}
|
||
|
||
/// 创建摄影师任务。
|
||
func createTask(_ request: AddTaskRequest) async throws {
|
||
let _: EmptyResponse = try await client.send(
|
||
APIRequest(
|
||
method: .post,
|
||
path: "/api/yf-handset-app/photog/task/create",
|
||
body: request
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 拉取当前景区可关联订单列表。
|
||
func availableOrders(scenicId: Int) async throws -> [AvailableOrder] {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/yf-handset-app/photog/task/available-order",
|
||
queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicId))]
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 拉取云盘文件列表。
|
||
func cloudFileList(
|
||
parentFolderId: Int,
|
||
name: String = "",
|
||
type: Int = 0,
|
||
orderBy: Int = 2,
|
||
page: Int = 1,
|
||
pageSize: Int = 20
|
||
) async throws -> CloudFileListResponse {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/yf-handset-app/photog/cloud-driver/list",
|
||
queryItems: [
|
||
URLQueryItem(name: "parent_folder_id", value: String(parentFolderId)),
|
||
URLQueryItem(name: "name", value: name),
|
||
URLQueryItem(name: "type", value: String(type)),
|
||
URLQueryItem(name: "order_by", value: String(orderBy)),
|
||
URLQueryItem(name: "page", value: String(page)),
|
||
URLQueryItem(name: "page_size", value: String(pageSize)),
|
||
]
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 登记 OSS 上传后的文件 URL。
|
||
func registerUploadedFileURL(scenicId: Int, fileURL: String, folderId: Int = 0) async throws {
|
||
let _: EmptyResponse = try await client.send(
|
||
APIRequest(
|
||
method: .post,
|
||
path: "/api/yf-handset-app/photog/album/file-upload-url",
|
||
queryItems: [
|
||
URLQueryItem(name: "scenic_id", value: String(scenicId)),
|
||
URLQueryItem(name: "file_url", value: fileURL),
|
||
URLQueryItem(name: "folder_id", value: String(folderId)),
|
||
]
|
||
)
|
||
)
|
||
}
|
||
}
|
||
|
||
/// 空响应占位,用于无 data 字段的成功接口。
|
||
private struct EmptyResponse: Decodable, Sendable {}
|