67 lines
2.0 KiB
Swift
67 lines
2.0 KiB
Swift
//
|
||
// 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),
|
||
]
|
||
)
|
||
)
|
||
}
|
||
}
|