// // CloudDriveModels.swift // suixinkan // import Foundation /// 云盘文件/文件夹实体,对齐 Android `CloudFileEntity`。 struct CloudFile: Codable, Sendable, Equatable, Hashable { let id: Int let parentFolderId: Int let fileUrl: String let coverUrl: String let updatedAt: String let name: String let createdAt: String let childNum: Int let type: Int let fileSize: Int64 enum CodingKeys: String, CodingKey { case id case parentFolderId = "parent_folder_id" case fileUrl = "file_url" case coverUrl = "cover_url" case updatedAt = "updated_at" case name case createdAt = "created_at" case childNum = "child_num" case type case fileSize = "file_size" } init( id: Int = 0, parentFolderId: Int = 0, fileUrl: String = "", coverUrl: String = "", updatedAt: String = "", name: String = "", createdAt: String = "", childNum: Int = 0, type: Int = 0, fileSize: Int64 = 0 ) { self.id = id self.parentFolderId = parentFolderId self.fileUrl = fileUrl self.coverUrl = coverUrl self.updatedAt = updatedAt self.name = name self.createdAt = createdAt self.childNum = childNum self.type = type self.fileSize = fileSize } /// 是否为文件夹。 var isFolder: Bool { type == 99 } /// 是否为图片。 var isImage: Bool { type == 2 } /// 是否为视频。 var isVideo: Bool { type == 1 } /// 是否为可导入的媒体文件。 var isSelectableMedia: Bool { isImage || isVideo } } /// 云盘列表响应。 struct CloudFileListResponse: Codable, Sendable, Equatable { let total: Int let list: [CloudFile] init(total: Int = 0, list: [CloudFile] = []) { self.total = total self.list = list } } /// 云盘路径节点,用于面包屑导航。 struct CloudPathItem: Codable, Sendable, Equatable, Hashable { let id: Int let name: String } /// 云盘上传权限响应。 struct CloudUploadPermissionResponse: Decodable, Sendable, Equatable { let canUpload: Bool let reason: String enum CodingKeys: String, CodingKey { case canUpload = "can_upload" case reason } } /// 云盘删除请求体。 struct CloudFileDeleteRequest: Encodable, Sendable, Equatable { let list: [CloudFileOperationItem] } /// 云盘移动请求体。 struct CloudFileMoveRequest: Encodable, Sendable, Equatable { let targetFolderId: Int let list: [CloudFileOperationItem] enum CodingKeys: String, CodingKey { case targetFolderId = "target_folder_id" case list } } /// 云盘删除/移动文件项。 struct CloudFileOperationItem: Codable, Sendable, Equatable { let id: Int let type: Int } /// 云盘创建文件夹请求体。 struct CloudFolderCreateRequest: Encodable, Sendable, Equatable { let parentFolderId: Int let name: String enum CodingKeys: String, CodingKey { case parentFolderId = "parent_folder_id" case name } } /// 云盘文件上传登记请求体。 struct CloudFileUploadRequest: Encodable, Sendable, Equatable { let parentFolderId: Int let fileUrl: String let fileName: String enum CodingKeys: String, CodingKey { case parentFolderId = "parent_folder_id" case fileUrl = "file_url" case fileName = "file_name" } } /// 云盘文件夹改名请求体。 struct CloudFolderModifyRequest: Encodable, Sendable, Equatable { let fileId: Int let name: String enum CodingKeys: String, CodingKey { case fileId = "id" case name } } /// 云盘文件改名请求体。 struct CloudFileModifyRequest: Encodable, Sendable, Equatable { let fileId: Int let fileName: String enum CodingKeys: String, CodingKey { case fileId = "id" case fileName = "file_name" } }