订阅明确无缓存时使用新发起的有效 HTTP 全量响应衔接首包,保留任务、批次和版本校验。 移除 Debug/Release 的设备指令、图传和 RTC 构建拦截,保留后端权限、身份、防重复提交及结果未知保护。 更新开发约定并补充隔离传输、飞控状态和页面回归测试。 验证:iPhone 真机 500 项相关测试通过;iOS Release 无签名编译通过。
40 lines
1.8 KiB
Swift
40 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
/// 朱工开始拍摄服务,只使用已创建并召唤的订单飞行任务身份。
|
|
protocol DroneDockStartShooting: Sendable {
|
|
/// 提交一次开拍请求;调用方负责校验执行门禁并阻止重复提交。
|
|
@MainActor
|
|
func startShooting(taskID: Int) async throws -> DroneDockStartShootResponse
|
|
}
|
|
|
|
/// start-shoot 合同适配;两种构建共用任务身份校验和单次提交规则。
|
|
@MainActor
|
|
final class DroneDockStartShootAPI: DroneDockStartShooting {
|
|
private let client: APIClient
|
|
|
|
/// 注入统一客户端,测试使用不会联网的本地模拟传输。
|
|
init(client: APIClient) { self.client = client }
|
|
|
|
/// 仅 POST 任务 ID,不附带飞机、航线或未约定的模拟参数,也不自动重试。
|
|
func startShooting(taskID: Int) async throws -> DroneDockStartShootResponse {
|
|
try Task.checkCancellation()
|
|
guard taskID > 0 else { throw APIError.networkFailed("缺少有效拍摄任务 ID,请返回任务页确认") }
|
|
let response: DroneDockStartShootResponse = try await client.send(APIRequest(
|
|
method: .post, path: "/api/app/airport/start-shoot", body: StartShootBody(taskID: taskID)
|
|
))
|
|
guard let returnedID = response.orderFlightTaskID, returnedID > 0, returnedID == taskID,
|
|
response.orderFlightTask?.id == nil || response.orderFlightTask?.id == taskID else {
|
|
throw APIError.decodeFailed("开始拍摄回执的任务身份缺失或不一致,请核对原任务状态")
|
|
}
|
|
return response
|
|
}
|
|
|
|
/// 开拍只提交订单飞行任务身份,不使用航线任务 ID。
|
|
private struct StartShootBody: Encodable {
|
|
let taskID: Int
|
|
|
|
/// 朱工开拍请求的 JSON 字段。
|
|
private enum CodingKeys: String, CodingKey { case taskID = "id" }
|
|
}
|
|
}
|