feat: 添加云盘与消息中心功能

This commit is contained in:
2026-07-09 22:37:43 +08:00
parent 8e356973bd
commit f20ec7f06c
91 changed files with 5437 additions and 89 deletions

View File

@ -0,0 +1,144 @@
//
// CloudDriveAPI.swift
// suixinkan
//
import Foundation
/// 便 ViewModel
@MainActor
protocol CloudDriveServing {
///
func cloudFileList(
parentFolderId: Int,
name: String,
type: Int,
orderBy: Int,
page: Int,
pageSize: Int
) async throws -> CloudFileListResponse
///
func createCloudFolder(parentFolderId: Int, name: String) async throws
/// OSS
func uploadCloudFile(parentFolderId: Int, fileUrl: String, fileName: String) async throws
///
func deleteCloudFiles(_ request: CloudFileDeleteRequest) async throws
///
func moveCloudFiles(_ request: CloudFileMoveRequest) async throws
///
func checkUploadPermission() async throws -> CloudUploadPermissionResponse
///
func modifyCloudFolderName(fileId: Int, name: String) async throws
///
func modifyCloudFileName(fileId: Int, fileName: String) async throws
}
@MainActor
/// API Android `NetworkApi` cloud-driver
final class CloudDriveAPI: CloudDriveServing {
private let client: APIClient
init(client: APIClient) {
self.client = client
}
func cloudFileList(
parentFolderId: Int,
name: String = "",
type: Int = 0,
orderBy: Int = 2,
page: Int = 1,
pageSize: Int = 20
) async throws -> CloudFileListResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/cloud-driver/list",
queryItems: [
URLQueryItem(name: "parent_folder_id", value: String(parentFolderId)),
URLQueryItem(name: "name", value: name),
URLQueryItem(name: "type", value: String(type)),
URLQueryItem(name: "order_by", value: String(orderBy)),
URLQueryItem(name: "page", value: String(page)),
URLQueryItem(name: "page_size", value: String(pageSize)),
]
)
)
}
func createCloudFolder(parentFolderId: Int, name: String) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/cloud-driver/folder-create",
body: CloudFolderCreateRequest(parentFolderId: parentFolderId, name: name)
)
)
}
func uploadCloudFile(parentFolderId: Int, fileUrl: String, fileName: String) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/cloud-driver/file-upload",
body: CloudFileUploadRequest(parentFolderId: parentFolderId, fileUrl: fileUrl, fileName: fileName)
)
)
}
func deleteCloudFiles(_ request: CloudFileDeleteRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/cloud-driver/delete",
body: request
)
)
}
func moveCloudFiles(_ request: CloudFileMoveRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/cloud-driver/move",
body: request
)
)
}
func checkUploadPermission() async throws -> CloudUploadPermissionResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/cloud-driver/check-upload-permission"
)
)
}
func modifyCloudFolderName(fileId: Int, name: String) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/cloud-driver/folder-edit",
body: CloudFolderModifyRequest(fileId: fileId, name: name)
)
)
}
func modifyCloudFileName(fileId: Int, fileName: String) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/cloud-driver/file-edit",
body: CloudFileModifyRequest(fileId: fileId, fileName: fileName)
)
)
}
}