添加网络层并接入 v9 登录流程及单元测试

This commit is contained in:
2026-07-06 15:33:34 +08:00
parent 31ffec0f2b
commit d424928243
21 changed files with 2387 additions and 18 deletions

View File

@ -0,0 +1,47 @@
//
// AuthAPI.swift
// suixinkan
//
import Foundation
@MainActor
/// API configv9
final class AuthAPI {
private let client: APIClient
/// API
init(client: APIClient) {
self.client = client
}
/// App /
func getAppConfig() async throws -> AppConfigResponse {
try await client.send(
APIRequest(method: .get, path: "/api/app/config")
)
}
/// 使 v9 token
func login(username: String, password: String) async throws -> V9AuthResponse {
try await client.send(
APIRequest(
method: .post,
path: "/api/app/v9/login",
body: LoginRequest(username: username, password: password)
)
)
}
/// token
func setUser(_ request: SetUserRequest, tokenOverride: String? = nil) async throws -> V9AuthResponse {
try await client.send(
APIRequest(
method: .post,
path: "/api/app/v9/set-user",
body: request
),
tokenOverride: tokenOverride
)
}
}