新增景区排队管理功能

This commit is contained in:
2026-07-07 15:32:25 +08:00
parent 854a66689f
commit 0aa8b14e1f
20 changed files with 4642 additions and 1 deletions

View File

@ -0,0 +1,215 @@
//
// ScenicQueueAPI.swift
// suixinkan
//
import Foundation
@MainActor
/// API 便 ViewModel
protocol ScenicQueueAPIProtocol {
func saveSetting(_ request: ScenicQueueSaveSettingRequest) async throws
func call(recordId: Int64) async throws -> ScenicQueueCallData
func pass(recordId: Int64) async throws -> ScenicQueuePassData
func finish(recordId: Int64) async throws -> ScenicQueueFinishData
func userMark(_ request: ScenicQueueUserMarkRequest) async throws
func requeueInsertBefore(recordId: Int64, operatorId: Int) async throws
func shootQueueQrcode(scenicId: Int64, scenicSpotId: Int64) async throws -> ScenicQueueShootQueueQrcodeData
func setting(scenicId: Int64?, scenicSpotId: Int64?) async throws -> ScenicQueueSettingData
func stats(scenicId: Int64, scenicSpotId: Int64) async throws -> ScenicQueueStatsData
func home(scenicId: Int64, scenicSpotId: Int64, type: Int, page: Int, pageSize: Int) async throws -> ScenicQueueHomeData
func settingChangeLog(scenicId: Int64, scenicSpotId: Int64?, page: Int, pageSize: Int) async throws -> ScenicQueueSettingChangeLogData
func scenicSpotListAll(scenicId: String) async throws -> ScenicSpotListResponse
func socketToken() async throws -> SocketTokenResponse
func aliyunSTS(bucket: String) async throws -> AliyunOSSResponse
}
@MainActor
/// API Android `NetworkApi` scenic-queue
final class ScenicQueueAPI: ScenicQueueAPIProtocol {
private let client: APIClient
init(client: APIClient) {
self.client = client
}
///
func saveSetting(_ request: ScenicQueueSaveSettingRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/save-setting", body: request)
)
}
///
func call(recordId: Int64) async throws -> ScenicQueueCallData {
try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/call", body: ScenicQueueIdRequest(id: recordId))
)
}
///
func pass(recordId: Int64) async throws -> ScenicQueuePassData {
try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/pass", body: ScenicQueueIdRequest(id: recordId))
)
}
///
func finish(recordId: Int64) async throws -> ScenicQueueFinishData {
try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/finish", body: ScenicQueueIdRequest(id: recordId))
)
}
///
func userMark(_ request: ScenicQueueUserMarkRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(method: .post, path: "/api/app/scenic-queue/user-mark", body: request)
)
}
///
func requeueInsertBefore(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 shootQueueQrcode(scenicId: Int64, scenicSpotId: Int64) 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 setting(scenicId: Int64?, scenicSpotId: Int64?) async throws -> ScenicQueueSettingData {
var items: [URLQueryItem] = []
if let scenicId {
items.append(URLQueryItem(name: "scenic_id", value: String(scenicId)))
}
if let scenicSpotId {
items.append(URLQueryItem(name: "scenic_spot_id", value: String(scenicSpotId)))
}
return try await client.send(
APIRequest(method: .get, path: "/api/app/scenic-queue/setting", queryItems: items)
)
}
///
func stats(scenicId: Int64, scenicSpotId: Int64) async throws -> ScenicQueueStatsData {
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)),
]
)
)
}
///
func home(scenicId: Int64, scenicSpotId: Int64, type: Int, page: Int, pageSize: Int) async throws -> ScenicQueueHomeData {
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(page)),
URLQueryItem(name: "page_size", value: String(pageSize)),
]
)
)
}
///
func settingChangeLog(scenicId: Int64, scenicSpotId: Int64?, page: Int, pageSize: Int) async throws -> ScenicQueueSettingChangeLogData {
var items = [
URLQueryItem(name: "scenic_id", value: String(scenicId)),
URLQueryItem(name: "page", value: String(page)),
URLQueryItem(name: "page_size", value: String(pageSize)),
]
if let scenicSpotId {
items.append(URLQueryItem(name: "scenic_spot_id", value: String(scenicSpotId)))
}
return try await client.send(
APIRequest(method: .get, path: "/api/app/scenic-queue/setting-change-log", queryItems: items)
)
}
///
func scenicSpotListAll(scenicId: String) async throws -> ScenicSpotListResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/scenic-spot/list-all",
queryItems: [URLQueryItem(name: "scenic_id", value: scenicId)]
)
)
}
/// WebSocket token
func socketToken() async throws -> SocketTokenResponse {
try await client.send(APIRequest(method: .get, path: "/api/app/socket-token"))
}
/// STS
func aliyunSTS(bucket: String = "vipsky") async throws -> AliyunOSSResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/app/config/get-sts-token",
queryItems: [URLQueryItem(name: "bucket", value: bucket)]
)
)
}
}
/// id
struct ScenicQueueIdRequest: Encodable, Equatable {
let id: Int64
}
///
struct ScenicQueueRequeueInsertBeforeRequest: Encodable, Equatable {
let recordId: Int64
let operatorId: Int
enum CodingKeys: String, CodingKey {
case recordId = "record_id"
case operatorId = "operator_id"
}
}
///
struct ScenicQueueUserMarkRequest: Encodable, Equatable {
let uid: Int64
let scenicId: Int64
let markAsFreelancePhotog: Int
let queueBanDays: Int?
let operatorId: Int?
enum CodingKeys: String, CodingKey {
case uid
case scenicId = "scenic_id"
case markAsFreelancePhotog = "mark_as_freelance_photog"
case queueBanDays = "queue_ban_days"
case operatorId = "operator_id"
}
}