Files
suixinkan_uikit/suixinkan/Features/Home/API/HomeAPI.swift
汉秋 efb3925257 完善首页权限申请流程与队列播报体验。
对齐 Android 无权限强制弹窗、角色下拉与申请页交互,补充 UIButton configuration 适配,并增强景区排队 TTS 与相关单元测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 13:46:45 +08:00

140 lines
4.5 KiB
Swift
Raw 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.

//
// HomeAPI.swift
// suixinkan
//
import Foundation
@MainActor
/// API
final class HomeAPI {
private let client: APIClient
init(client: APIClient) {
self.client = client
}
///
func rolePermissions() async throws -> [RolePermissionResponse] {
try await client.send(
APIRequest(method: .get, path: "/api/yf-handset-app/role-permission")
)
}
///
func storeList() async throws -> StoreListResponse {
try await client.send(
APIRequest(method: .get, path: "/api/app/store/all")
)
}
///
func locationDetail(staffId: String) async throws -> LocationDetailResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/loacation/detail",
queryItems: [URLQueryItem(name: "staff_id", value: staffId)]
)
)
}
///
func reportLocation(
staffId: String,
latitude: Double,
longitude: Double,
address: String,
type: Int,
scenicId: String
) async throws -> LocationReportResponse {
try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/loacation/report",
queryItems: [
URLQueryItem(name: "staff_id", value: staffId),
URLQueryItem(name: "latitude", value: String(latitude)),
URLQueryItem(name: "longitude", value: String(longitude)),
URLQueryItem(name: "address", value: address),
URLQueryItem(name: "type", value: String(type)),
URLQueryItem(name: "scenic_id", value: scenicId),
]
)
)
}
///
func locationReportList(
staffId: String,
page: Int,
pageSize: Int,
type: Int,
startDate: String?,
endDate: String?
) async throws -> LocationReportHistoryListResponse {
var queryItems = [
URLQueryItem(name: "staff_id", value: staffId),
URLQueryItem(name: "page", value: String(page)),
URLQueryItem(name: "page_size", value: String(pageSize)),
URLQueryItem(name: "type", value: String(type)),
]
if let startDate, !startDate.isEmpty {
queryItems.append(URLQueryItem(name: "start_date", value: startDate))
}
if let endDate, !endDate.isEmpty {
queryItems.append(URLQueryItem(name: "end_date", value: endDate))
}
return try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/loacation/list",
queryItems: queryItems
)
)
}
///
func roleApplyPending() async throws -> [RoleApplyPendingResponse] {
try await client.send(
APIRequest(method: .get, path: "/api/yf-handset-app/photog/role-apply/all")
)
}
///
func scenicListAll() async throws -> ScenicListAllResponse {
try await client.send(
APIRequest(method: .get, path: "/api/yf-handset-app/photog/scenic/list-all")
)
}
///
func submitRoleApply(scenicIds: [Int], roleId: Int) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/role-apply/submit",
body: RoleApplySubmitRequest(scenicId: scenicIds, roleId: roleId)
)
)
}
///
func scenicApplicationPending() async throws -> ScenicApplicationPendingsResponse {
try await client.send(
APIRequest(method: .get, path: "/api/yf-handset-app/photog/scenic-apply/all")
)
}
///
func submitScenicApplication(_ request: ScenicApplicationSubmitRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/scenic-apply/submit",
body: request
)
)
}
}