feat: 定义仓库协议与用例(含会话)

This commit is contained in:
AndyChen1024
2026-09-15 14:35:52 +08:00
parent 14eb5ad44d
commit ec1eed8f04
10 changed files with 139 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
/// 会话用例。
public struct SessionUseCase: Sendable {
private let repository: SessionRepository
public init(repository: SessionRepository) {
self.repository = repository
}
public func observeIsLoggedIn() -> AsyncThrowingStream<Bool, Error> {
repository.observeIsLoggedIn()
}
public func requestSmsCode(phone: String) async throws {
try await repository.requestSmsCode(phone: phone)
}
public func login(phone: String, code: String) async throws {
try await repository.login(phone: phone, code: code)
}
public func logout() async throws {
try await repository.logout()
}
}