// // AccountContextAPI.swift // suixinkan // // Created by Codex on 2026/6/22. // import Foundation import Combine @MainActor /// 账号上下文服务协议,抽象权限、景区、门店和景点读取能力以便测试替换。 protocol AccountContextServing { /// 获取当前账号的角色权限列表。 func rolePermissions() async throws -> [RolePermissionResponse] /// 获取当前账号可访问的景区列表。 func scenicListAll() async throws -> ScenicListAllResponse /// 获取当前账号可访问的门店列表。 func storeAll() async throws -> ListPayload /// 获取指定景区下的景点或打卡点列表。 func scenicSpotListAll(scenicId: Int) async throws -> ListPayload } @MainActor /// 账号上下文 API,封装角色权限、景区、门店和景点读取接口。 final class AccountContextAPI: AccountContextServing { private let client: APIClient /// 初始化账号上下文 API,并注入共享网络客户端。 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 scenicListAll() async throws -> ScenicListAllResponse { try await client.send( APIRequest( method: .get, path: "/api/yf-handset-app/photog/scenic/list-all" ) ) } /// 获取当前账号可访问的门店列表。 func storeAll() async throws -> ListPayload { try await client.send( APIRequest( method: .get, path: "/api/app/store/all" ) ) } /// 获取指定景区下的景点或打卡点列表。 func scenicSpotListAll(scenicId: Int) async throws -> ListPayload { try await client.send( APIRequest( method: .get, path: "/api/yf-handset-app/photog/scenic-spot/list-all", queryItems: [URLQueryItem(name: "scenic_id", value: "\(scenicId)")] ) ) } }