Files
suixinkan_ios_new/suixinkan/Features/LocationReport/API/LocationReportAPI.swift
汉秋 26f4d0e671 Migrate from iOS 17 Observation to iOS 16-compatible Combine architecture.
Lower deployment target to iOS 16, replace @Observable with ObservableObject, add navigation and UI compatibility shims, and include login smoke UI tests.

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

82 lines
2.9 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.

//
// LocationReportAPI.swift
// suixinkan
//
// Created by Codex on 2026/6/24.
//
import Foundation
import Combine
/// 便 ViewModel
@MainActor
protocol LocationReportServing {
///
func reportLocation(staffId: Int, latitude: Double, longitude: Double, address: String, type: LocationReportType, scenicId: Int) async throws -> LocationReportSubmitResponse
///
func locationReportList(staffId: Int, page: Int, pageSize: Int, type: LocationReportType, startDate: String?, endDate: String?) async throws -> ListPayload<LocationReportHistoryItem>
}
/// API
@MainActor
final class LocationReportAPI: LocationReportServing {
private let client: APIClient
/// API
init(client: APIClient) {
self.client = client
}
///
func reportLocation(
staffId: Int,
latitude: Double,
longitude: Double,
address: String,
type: LocationReportType,
scenicId: Int
) async throws -> LocationReportSubmitResponse {
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: "\(latitude)"),
URLQueryItem(name: "longitude", value: "\(longitude)"),
URLQueryItem(name: "address", value: address),
URLQueryItem(name: "type", value: "\(type.rawValue)"),
URLQueryItem(name: "scenic_id", value: "\(scenicId)")
]
)
)
}
///
func locationReportList(
staffId: Int,
page: Int = 1,
pageSize: Int = 20,
type: LocationReportType = .all,
startDate: String? = nil,
endDate: String? = nil
) async throws -> ListPayload<LocationReportHistoryItem> {
var query = [
URLQueryItem(name: "staff_id", value: "\(staffId)"),
URLQueryItem(name: "page", value: "\(max(page, 1))"),
URLQueryItem(name: "page_size", value: "\(max(pageSize, 1))"),
URLQueryItem(name: "type", value: "\(max(type.rawValue, 0))")
]
if let startDate, !startDate.isEmpty {
query.append(URLQueryItem(name: "start_date", value: startDate))
}
if let endDate, !endDate.isEmpty {
query.append(URLQueryItem(name: "end_date", value: endDate))
}
return try await client.send(
APIRequest(method: .get, path: "/api/yf-handset-app/photog/loacation/list", queryItems: query)
)
}
}