Extract dependency wiring and session lifecycle from the container and RootViewController, split NetworkBundle by domain, and add module-level feature services while keeping flat accessors for compatibility. Co-authored-by: Cursor <cursoragent@cursor.com>
166 lines
6.0 KiB
Swift
166 lines
6.0 KiB
Swift
//
|
||
// AppServicesBundles.swift
|
||
// suixinkan
|
||
//
|
||
// Created by Codex on 2026/6/26.
|
||
//
|
||
|
||
import Foundation
|
||
|
||
@MainActor
|
||
/// 登录与会话恢复相关依赖分组。
|
||
struct SessionBundle {
|
||
let appSession: AppSession
|
||
let authSessionCoordinator: AuthSessionCoordinator
|
||
let sessionBootstrapper: SessionBootstrapper
|
||
}
|
||
|
||
@MainActor
|
||
/// 账号、权限与景区景点等业务作用域 Context 分组。
|
||
struct AppContextBundle {
|
||
let accountContext: AccountContext
|
||
let permissionContext: PermissionContext
|
||
let scenicSpotContext: ScenicSpotContext
|
||
}
|
||
|
||
@MainActor
|
||
/// 网络层依赖分组,共享同一 `APIClient` 与 token 链路。
|
||
struct NetworkBundle {
|
||
let apiClient: APIClient
|
||
let account: AccountNetworkBundle
|
||
let commerce: CommerceNetworkBundle
|
||
let operation: OperationNetworkBundle
|
||
let content: ContentNetworkBundle
|
||
|
||
var authAPI: AuthAPI { account.authAPI }
|
||
var profileAPI: ProfileAPI { account.profileAPI }
|
||
var accountContextAPI: AccountContextAPI { account.accountContextAPI }
|
||
var pushAPI: PushAPI { account.pushAPI }
|
||
var ordersAPI: OrdersAPI { commerce.ordersAPI }
|
||
var paymentAPI: PaymentAPI { commerce.paymentAPI }
|
||
var walletAPI: WalletAPI { commerce.walletAPI }
|
||
var inviteAPI: InviteAPI { commerce.inviteAPI }
|
||
var scenicSettlementAPI: ScenicSettlementAPI { commerce.scenicSettlementAPI }
|
||
var statisticsAPI: StatisticsAPI { operation.statisticsAPI }
|
||
var scenicPermissionAPI: ScenicPermissionAPI { operation.scenicPermissionAPI }
|
||
var scenicQueueAPI: ScenicQueueAPI { operation.scenicQueueAPI }
|
||
var operatingAreaAPI: OperatingAreaAPI { operation.operatingAreaAPI }
|
||
var pilotCertificationAPI: PilotCertificationAPI { operation.pilotCertificationAPI }
|
||
var taskAPI: TaskAPI { operation.taskAPI }
|
||
var scheduleAPI: ScheduleAPI { operation.scheduleAPI }
|
||
var punchPointAPI: PunchPointAPI { operation.punchPointAPI }
|
||
var locationReportAPI: LocationReportAPI { operation.locationReportAPI }
|
||
var uploadAPI: UploadAPI { content.uploadAPI }
|
||
var ossUploadService: OSSUploadService { content.ossUploadService }
|
||
var messageCenterAPI: MessageCenterAPI { content.messageCenterAPI }
|
||
var liveAPI: LiveAPI { content.liveAPI }
|
||
var projectAPI: ProjectAPI { content.projectAPI }
|
||
var assetsAPI: AssetsAPI { content.assetsAPI }
|
||
|
||
/// 基于共享 `APIClient` 创建全部业务 API 分组。
|
||
init(apiClient: APIClient) {
|
||
self.apiClient = apiClient
|
||
account = AccountNetworkBundle(apiClient: apiClient)
|
||
commerce = CommerceNetworkBundle(apiClient: apiClient)
|
||
operation = OperationNetworkBundle(apiClient: apiClient)
|
||
content = ContentNetworkBundle(apiClient: apiClient)
|
||
}
|
||
}
|
||
|
||
@MainActor
|
||
/// 账号、登录、资料和推送相关网络依赖。
|
||
struct AccountNetworkBundle {
|
||
let authAPI: AuthAPI
|
||
let profileAPI: ProfileAPI
|
||
let accountContextAPI: AccountContextAPI
|
||
let pushAPI: PushAPI
|
||
|
||
/// 基于共享 `APIClient` 创建账号网络依赖。
|
||
init(apiClient: APIClient) {
|
||
authAPI = AuthAPI(client: apiClient)
|
||
profileAPI = ProfileAPI(client: apiClient)
|
||
accountContextAPI = AccountContextAPI(client: apiClient)
|
||
pushAPI = PushAPI(client: apiClient)
|
||
}
|
||
}
|
||
|
||
@MainActor
|
||
/// 订单、收款、钱包、邀请和结算相关网络依赖。
|
||
struct CommerceNetworkBundle {
|
||
let ordersAPI: OrdersAPI
|
||
let paymentAPI: PaymentAPI
|
||
let walletAPI: WalletAPI
|
||
let inviteAPI: InviteAPI
|
||
let scenicSettlementAPI: ScenicSettlementAPI
|
||
|
||
/// 基于共享 `APIClient` 创建交易网络依赖。
|
||
init(apiClient: APIClient) {
|
||
ordersAPI = OrdersAPI(client: apiClient)
|
||
paymentAPI = PaymentAPI(client: apiClient)
|
||
walletAPI = WalletAPI(client: apiClient)
|
||
inviteAPI = InviteAPI(client: apiClient)
|
||
scenicSettlementAPI = ScenicSettlementAPI(client: apiClient)
|
||
}
|
||
}
|
||
|
||
@MainActor
|
||
/// 运营管理、权限、排队、任务、排期和位置上报相关网络依赖。
|
||
struct OperationNetworkBundle {
|
||
let statisticsAPI: StatisticsAPI
|
||
let scenicPermissionAPI: ScenicPermissionAPI
|
||
let scenicQueueAPI: ScenicQueueAPI
|
||
let operatingAreaAPI: OperatingAreaAPI
|
||
let pilotCertificationAPI: PilotCertificationAPI
|
||
let taskAPI: TaskAPI
|
||
let scheduleAPI: ScheduleAPI
|
||
let punchPointAPI: PunchPointAPI
|
||
let locationReportAPI: LocationReportAPI
|
||
|
||
/// 基于共享 `APIClient` 创建运营网络依赖。
|
||
init(apiClient: APIClient) {
|
||
statisticsAPI = StatisticsAPI(client: apiClient)
|
||
scenicPermissionAPI = ScenicPermissionAPI(client: apiClient)
|
||
scenicQueueAPI = ScenicQueueAPI(client: apiClient)
|
||
operatingAreaAPI = OperatingAreaAPI(client: apiClient)
|
||
pilotCertificationAPI = PilotCertificationAPI(client: apiClient)
|
||
taskAPI = TaskAPI(client: apiClient)
|
||
scheduleAPI = ScheduleAPI(client: apiClient)
|
||
punchPointAPI = PunchPointAPI(client: apiClient)
|
||
locationReportAPI = LocationReportAPI(client: apiClient)
|
||
}
|
||
}
|
||
|
||
@MainActor
|
||
/// 内容、素材、直播、项目和消息中心相关网络依赖。
|
||
struct ContentNetworkBundle {
|
||
let uploadAPI: UploadAPI
|
||
let ossUploadService: OSSUploadService
|
||
let messageCenterAPI: MessageCenterAPI
|
||
let liveAPI: LiveAPI
|
||
let projectAPI: ProjectAPI
|
||
let assetsAPI: AssetsAPI
|
||
|
||
/// 基于共享 `APIClient` 创建内容网络依赖。
|
||
init(apiClient: APIClient) {
|
||
uploadAPI = UploadAPI(client: apiClient)
|
||
ossUploadService = OSSUploadService(configService: uploadAPI)
|
||
messageCenterAPI = MessageCenterAPI(client: apiClient)
|
||
liveAPI = LiveAPI(client: apiClient)
|
||
projectAPI = ProjectAPI(client: apiClient)
|
||
assetsAPI = AssetsAPI(client: apiClient)
|
||
}
|
||
}
|
||
|
||
@MainActor
|
||
/// 全局 UI 反馈(Toast、Loading)分组。
|
||
struct UIFeedbackBundle {
|
||
let toastCenter: ToastCenter
|
||
let globalLoading: GlobalLoadingCenter
|
||
}
|
||
|
||
@MainActor
|
||
/// 与登录态联动的后台运行时依赖分组。
|
||
struct AppRuntimeBundle {
|
||
let scenicQueueRuntime: ScenicQueueRuntime
|
||
}
|