接入 plane-status、tasks/create、shoot 与 shooting,保持同一任务 ID 串接、重复提交保护和只读单次刷新。拍摄任务页固定顶部参数与底部安全控制,中间状态区域适配小屏且不滚动;同步接口记录、脱敏响应及相关测试。
45 lines
1.8 KiB
Swift
45 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
/// 对已创建的订单飞行任务请求召唤,复用该任务及服务端锁定的飞机。
|
|
protocol DroneDockShootServing: Sendable {
|
|
/// 只提交已有任务 ID;调用方负责防止重复提交及核对不确定结果。
|
|
@MainActor
|
|
func shoot(taskID: Int) async throws -> DroneDockShootResponse
|
|
}
|
|
|
|
/// 朱工 shoot 接口适配,业务成功仅表示接口受理结果,不推断飞机已经到达。
|
|
@MainActor
|
|
final class DroneDockShootAPI: DroneDockShootServing {
|
|
private let client: APIClient
|
|
|
|
/// 注入统一网络客户端,沿用登录凭证、HTTP 与业务码处理。
|
|
init(client: APIClient) { self.client = client }
|
|
|
|
/// 仅发送一次召唤 POST;不创建任务、不重试、不修改任务已选航线。
|
|
func shoot(taskID: Int) async throws -> DroneDockShootResponse {
|
|
try Task.checkCancellation()
|
|
guard taskID > 0 else { throw APIError.networkFailed("缺少有效拍摄任务 ID,请先创建任务") }
|
|
do {
|
|
return try await client.send(APIRequest(
|
|
method: .post,
|
|
path: "/api/app/airport/shoot",
|
|
body: ShootBody(taskID: taskID)
|
|
))
|
|
} catch APIError.emptyData {
|
|
// 统一客户端仅在 HTTP 和业务码均成功后抛 emptyData;此接口尚未约定成功 data 结构。
|
|
return DroneDockShootResponse(dataJSON: nil)
|
|
}
|
|
}
|
|
|
|
/// 本轮联调仅发送任务身份和非重启标记,完全省略 plane_id 与航线覆盖字段。
|
|
private struct ShootBody: Encodable {
|
|
let taskID: Int
|
|
let restart = false
|
|
|
|
/// 朱工已建任务召唤参数映射。
|
|
private enum CodingKeys: String, CodingKey {
|
|
case taskID = "id", restart
|
|
}
|
|
}
|
|
}
|