Files
2026-06-26 14:33:31 +08:00

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

//
// PunchPointAPI.swift
// suixinkan
//
// Created by Codex on 2026/6/24.
//
import Foundation
/// 便
@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
final class PunchPointAPI: PunchPointServing {
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
}
}