Files
汉秋 d99a5b1bf8 Advance UIKit rewrite with AMap integration and core UI modules.
Integrate高德 SDK with simulator-safe build flags, add map views for operating area and punch points, refactor main tabs and key feature screens to UIKit with Diffable lists, and document Swift concurrency defaults in AGENTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 15:16:12 +08:00

212 lines
8.2 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// ScenicQueueAPI.swift
// suixinkan
//
// Created by Codex on 2026/6/25.
//
import Foundation
/// token
@MainActor
protocol ScenicQueueServing: AnyObject {
/// scenic
func scenicQueueStats(scenicId: Int, scenicSpotId: Int) async throws -> ScenicQueueStatsData
/// scenicHome
func scenicQueueHome(scenicId: Int, scenicSpotId: Int, type: Int, page: Int, pageSize: Int) async throws -> ScenicQueueHomeData
/// socket
func socketToken() async throws -> SocketTokenResponse
/// scenicCall
func scenicQueueCall(id: Int64) async throws -> ScenicQueueCallData
/// scenicPass
func scenicQueuePass(id: Int64) async throws -> ScenicQueuePassData
/// scenicFinish
func scenicQueueFinish(id: Int64) async throws -> ScenicQueueFinishData
/// scenicRequeueInsertBefore
func scenicQueueRequeueInsertBefore(recordId: Int64, operatorId: Int) async throws
/// scenicUserMark
func scenicQueueUserMark(_ request: ScenicQueueUserMarkRequest) async throws
/// scenicSetting
func scenicQueueSetting(scenicId: Int, scenicSpotId: Int?) async throws -> ScenicQueueSettingData
/// scenicSetting
func scenicQueueSaveSetting(_ request: ScenicQueueSaveSettingRequest) async throws
/// scenicShootQRCode
func scenicQueueShootQueueQRCode(scenicId: Int, scenicSpotId: Int) async throws -> ScenicQueueShootQueueQRCodeData
/// scenicSettingChangeLog
func scenicQueueSettingChangeLog(scenicId: Int, scenicSpotId: Int?, page: Int, pageSize: Int) async throws -> ScenicQueueSettingChangeLogData
}
@MainActor
/// API `/api/app/scenic-queue`
final class ScenicQueueAPI {
private let client: APIClient
/// API
init(client: APIClient) {
self.client = client
}
///
func scenicQueueStats(scenicId: Int, scenicSpotId: Int) async throws -> ScenicQueueStatsData {
do {
return try await client.send(
APIRequest(
method: .get,
path: "/api/app/scenic-queue/queue-stats",
queryItems: [
URLQueryItem(name: "scenic_id", value: String(scenicId)),
URLQueryItem(name: "scenic_spot_id", value: String(scenicSpotId))
]
)
)
} catch APIError.emptyData {
return ScenicQueueStatsData()
}
}
///
func scenicQueueHome(
scenicId: Int,
scenicSpotId: Int,
type: Int,
page: Int = 1,
pageSize: Int = 20
) async throws -> ScenicQueueHomeData {
do {
return try await client.send(
APIRequest(
method: .get,
path: "/api/app/scenic-queue/home",
queryItems: [
URLQueryItem(name: "scenic_id", value: String(scenicId)),
URLQueryItem(name: "scenic_spot_id", value: String(scenicSpotId)),
URLQueryItem(name: "type", value: String(type)),
URLQueryItem(name: "page", value: String(max(page, 1))),
URLQueryItem(name: "page_size", value: String(max(pageSize, 1)))
]
)
)
} catch APIError.emptyData {
return ScenicQueueHomeData()
}
}
/// WebSocket token
func socketToken() async throws -> SocketTokenResponse {
try await client.send(APIRequest(method: .get, path: "/api/app/socket-token"))
}
///
func scenicQueueCall(id: Int64) async throws -> ScenicQueueCallData {
do {
return try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/call", body: ScenicQueueActionRequest(id: id))
)
} catch APIError.emptyData {
return ScenicQueueCallData(id: id)
}
}
///
func scenicQueuePass(id: Int64) async throws -> ScenicQueuePassData {
do {
return try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/pass", body: ScenicQueueActionRequest(id: id))
)
} catch APIError.emptyData {
return ScenicQueuePassData(id: id)
}
}
///
func scenicQueueFinish(id: Int64) async throws -> ScenicQueueFinishData {
do {
return try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/finish", body: ScenicQueueActionRequest(id: id))
)
} catch APIError.emptyData {
return ScenicQueueFinishData(id: id)
}
}
///
func scenicQueueRequeueInsertBefore(recordId: Int64, operatorId: Int) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/app/scenic-queue/requeue-insert-before",
body: ScenicQueueRequeueInsertBeforeRequest(recordId: recordId, operatorId: operatorId)
)
)
}
/// /
func scenicQueueUserMark(_ request: ScenicQueueUserMarkRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/user-mark", body: request)
)
}
///
func scenicQueueSetting(scenicId: Int, scenicSpotId: Int?) async throws -> ScenicQueueSettingData {
var query = [URLQueryItem(name: "scenic_id", value: String(scenicId))]
if let scenicSpotId {
query.append(URLQueryItem(name: "scenic_spot_id", value: String(scenicSpotId)))
}
do {
return try await client.send(
APIRequest(method: .get, path: "/api/app/scenic-queue/setting", queryItems: query)
)
} catch APIError.emptyData {
return ScenicQueueSettingData()
}
}
///
func scenicQueueSaveSetting(_ request: ScenicQueueSaveSettingRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/save-setting", body: request)
)
}
///
func scenicQueueShootQueueQRCode(scenicId: Int, scenicSpotId: Int) async throws -> ScenicQueueShootQueueQRCodeData {
try await client.send(
APIRequest(
method: .get,
path: "/api/app/scenic-queue/shoot-queue-qrcode",
queryItems: [
URLQueryItem(name: "scenic_id", value: String(scenicId)),
URLQueryItem(name: "scenic_spot_id", value: String(scenicSpotId))
]
)
)
}
///
func scenicQueueSettingChangeLog(
scenicId: Int,
scenicSpotId: Int?,
page: Int = 1,
pageSize: Int = 20
) async throws -> ScenicQueueSettingChangeLogData {
var query = [
URLQueryItem(name: "scenic_id", value: String(scenicId)),
URLQueryItem(name: "page", value: String(max(page, 1))),
URLQueryItem(name: "page_size", value: String(max(pageSize, 1)))
]
if let scenicSpotId {
query.append(URLQueryItem(name: "scenic_spot_id", value: String(scenicSpotId)))
}
do {
return try await client.send(
APIRequest(method: .get, path: "/api/app/scenic-queue/setting-change-log", queryItems: query)
)
} catch APIError.emptyData {
return ScenicQueueSettingChangeLogData()
}
}
}
extension ScenicQueueAPI: ScenicQueueServing {}