// // 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 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 -> RoleApplySubmitResult { try await client.send( APIRequest( method: .post, path: "/api/yf-handset-app/photog/role-apply/submit", body: RoleApplySubmitRequest(scenicId: scenicIds, roleId: roleId) ) ) } }