Files
suixinkan_ios_new/suixinkan/Features/PunchPoint/API/PunchPointAPI.swift
汉秋 0d4b63d273 Add PunchPoint and LocationReport modules with home routing.
Migrate check-in point management and location reporting from placeholders to full MVVM flows, including foreground location support and unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:08:41 +08:00

89 lines
3.0 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.

//
// PunchPointAPI.swift
// suixinkan
//
// Created by Codex on 2026/6/24.
//
import Foundation
import Observation
/// 便
@MainActor
protocol PunchPointServing {
///
func punchPointList(scenicId: Int, status: Int, page: Int, pageSize: Int) async throws -> ListPayload<PunchPointItem>
///
func punchPointInfo(id: Int) async throws -> PunchPointItem
///
func addPunchPoint(_ request: AddPunchPointRequest) async throws
///
func editPunchPoint(_ request: EditPunchPointRequest) async throws
///
func deletePunchPoint(id: Int) async throws
}
/// API
@MainActor
@Observable
final class PunchPointAPI: PunchPointServing {
@ObservationIgnored private let client: APIClient
/// API
init(client: APIClient) {
self.client = client
}
///
func punchPointList(scenicId: Int, status: Int = 0, page: Int = 1, pageSize: Int = 20) async throws -> ListPayload<PunchPointItem> {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/scenic-spot/list",
queryItems: [
URLQueryItem(name: "scenic_area_id", value: "\(scenicId)"),
URLQueryItem(name: "status", value: "\(max(status, 0))"),
URLQueryItem(name: "page", value: "\(max(page, 1))"),
URLQueryItem(name: "page_size", value: "\(max(pageSize, 1))")
]
)
)
}
///
func punchPointInfo(id: Int) async throws -> PunchPointItem {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/scenic-spot/info",
queryItems: [URLQueryItem(name: "id", value: "\(id)")]
)
)
}
///
func addPunchPoint(_ request: AddPunchPointRequest) async throws {
_ = try await client.send(
APIRequest(method: .post, path: "/api/yf-handset-app/photog/scenic-spot/add", body: request)
) as EmptyPayload
}
///
func editPunchPoint(_ request: EditPunchPointRequest) async throws {
_ = try await client.send(
APIRequest(method: .post, path: "/api/yf-handset-app/photog/scenic-spot/edit", body: request)
) as EmptyPayload
}
///
func deletePunchPoint(id: Int) async throws {
_ = try await client.send(
APIRequest(method: .post, path: "/api/yf-handset-app/photog/scenic-spot/delete", body: PunchPointDeleteRequest(id: id))
) as EmptyPayload
}
}