将最低部署版本降至 iOS 16,以 ObservableObject 替换 @Observable,新增导航与 UI 兼容层,并补充登录冒烟 UI 测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
78 lines
2.3 KiB
Swift
78 lines
2.3 KiB
Swift
//
|
||
// 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<StoreItem>
|
||
|
||
/// 获取指定景区下的景点或打卡点列表。
|
||
func scenicSpotListAll(scenicId: Int) async throws -> ListPayload<ScenicSpotItem>
|
||
}
|
||
|
||
@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<StoreItem> {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/app/store/all"
|
||
)
|
||
)
|
||
}
|
||
|
||
/// 获取指定景区下的景点或打卡点列表。
|
||
func scenicSpotListAll(scenicId: Int) async throws -> ListPayload<ScenicSpotItem> {
|
||
try await client.send(
|
||
APIRequest(
|
||
method: .get,
|
||
path: "/api/yf-handset-app/photog/scenic-spot/list-all",
|
||
queryItems: [URLQueryItem(name: "scenic_id", value: "\(scenicId)")]
|
||
)
|
||
)
|
||
}
|
||
}
|