Add sample management and upload flows to Assets module.
Extend media library for sample kind with project selection, wire home routing for sample entries, and expand Assets tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
import Observation
|
||||
|
||||
/// 资产服务协议,抽象云盘和素材管理接口以便 ViewModel 测试替换。
|
||||
/// 资产服务协议,抽象云盘、媒体库和相册接口以便 ViewModel 测试替换。
|
||||
@MainActor
|
||||
protocol AssetsServing {
|
||||
/// 获取云盘文件列表。
|
||||
@ -35,27 +35,30 @@ protocol AssetsServing {
|
||||
/// 检查当前账号是否允许上传云盘文件。
|
||||
func checkCloudUploadPermission() async throws -> CheckCloudUploadResponse
|
||||
|
||||
/// 获取素材列表。
|
||||
/// 获取素材或样片列表。
|
||||
func mediaAlbumList(kind: MediaLibraryKind, keyword: String, status: Int?, page: Int, pageSize: Int) async throws -> MediaLibraryListResponse
|
||||
|
||||
/// 获取素材详情。
|
||||
func mediaAlbumDetail(id: Int) async throws -> MediaLibraryDetail
|
||||
/// 获取素材或样片详情。
|
||||
func mediaAlbumDetail(id: Int, kind: MediaLibraryKind) async throws -> MediaLibraryDetail
|
||||
|
||||
/// 更新素材上下架状态。
|
||||
/// 更新素材或样片上下架状态。
|
||||
func mediaAlbumOperation(_ request: MediaAlbumOperationRequest) async throws
|
||||
|
||||
/// 删除素材。
|
||||
/// 删除素材或样片。
|
||||
func mediaAlbumDelete(_ request: MediaAlbumDeleteRequest) async throws
|
||||
|
||||
/// 新增素材标签。
|
||||
func mediaAlbumAddTag(_ request: MediaAlbumAddTagRequest) async throws
|
||||
|
||||
/// 上传素材。
|
||||
/// 上传素材或样片。
|
||||
func mediaAlbumUpload(_ request: MediaAlbumUploadRequest) async throws
|
||||
|
||||
/// 编辑素材。
|
||||
func mediaAlbumEdit(_ request: MediaAlbumEditRequest) async throws
|
||||
|
||||
/// 获取样片上传可关联的项目列表。
|
||||
func projectList(scenicId: Int, name: String?, page: Int, pageSize: Int) async throws -> ListPayload<PhotographerProjectItem>
|
||||
|
||||
/// 获取相册文件夹列表。
|
||||
func albumFolderList(scenicId: Int, page: Int, pageSize: Int, name: String, startTime: String?, endTime: String?) async throws -> ListPayload<AlbumFolderItem>
|
||||
|
||||
@ -163,7 +166,7 @@ final class AssetsAPI: AssetsServing {
|
||||
)
|
||||
}
|
||||
|
||||
/// 获取素材列表。
|
||||
/// 获取素材或样片列表。
|
||||
func mediaAlbumList(
|
||||
kind: MediaLibraryKind = .material,
|
||||
keyword: String = "",
|
||||
@ -185,25 +188,28 @@ final class AssetsAPI: AssetsServing {
|
||||
)
|
||||
}
|
||||
|
||||
/// 获取素材详情。
|
||||
func mediaAlbumDetail(id: Int) async throws -> MediaLibraryDetail {
|
||||
/// 获取素材或样片详情。
|
||||
func mediaAlbumDetail(id: Int, kind: MediaLibraryKind = .material) async throws -> MediaLibraryDetail {
|
||||
try await client.send(
|
||||
APIRequest(
|
||||
method: .get,
|
||||
path: "/api/app/media-album/detail",
|
||||
queryItems: [URLQueryItem(name: "id", value: "\(id)")]
|
||||
queryItems: [
|
||||
URLQueryItem(name: "id", value: "\(id)"),
|
||||
URLQueryItem(name: "type", value: "\(kind.rawValue)")
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/// 更新素材上下架状态。
|
||||
/// 更新素材或样片上下架状态。
|
||||
func mediaAlbumOperation(_ request: MediaAlbumOperationRequest) async throws {
|
||||
_ = try await client.send(
|
||||
APIRequest(method: .post, path: "/api/app/media-album/operation", body: request)
|
||||
) as EmptyPayload
|
||||
}
|
||||
|
||||
/// 删除素材。
|
||||
/// 删除素材或样片。
|
||||
func mediaAlbumDelete(_ request: MediaAlbumDeleteRequest) async throws {
|
||||
_ = try await client.send(
|
||||
APIRequest(method: .post, path: "/api/app/media-album/delete", body: request)
|
||||
@ -217,7 +223,7 @@ final class AssetsAPI: AssetsServing {
|
||||
) as EmptyPayload
|
||||
}
|
||||
|
||||
/// 上传素材。
|
||||
/// 上传素材或样片。
|
||||
func mediaAlbumUpload(_ request: MediaAlbumUploadRequest) async throws {
|
||||
_ = try await client.send(
|
||||
APIRequest(method: .post, path: "/api/app/media-album/upload", body: request)
|
||||
@ -231,6 +237,26 @@ final class AssetsAPI: AssetsServing {
|
||||
) as EmptyPayload
|
||||
}
|
||||
|
||||
/// 获取样片上传可关联的项目列表。
|
||||
func projectList(
|
||||
scenicId: Int,
|
||||
name: String? = nil,
|
||||
page: Int = 1,
|
||||
pageSize: Int = 50
|
||||
) async throws -> ListPayload<PhotographerProjectItem> {
|
||||
var query = [
|
||||
URLQueryItem(name: "scenic_id", value: "\(scenicId)"),
|
||||
URLQueryItem(name: "page", value: "\(max(page, 1))"),
|
||||
URLQueryItem(name: "page_size", value: "\(max(pageSize, 1))")
|
||||
]
|
||||
if let name, !name.isEmpty {
|
||||
query.append(URLQueryItem(name: "name", value: name))
|
||||
}
|
||||
return try await client.send(
|
||||
APIRequest(method: .get, path: "/api/yf-handset-app/photog/project/list", queryItems: query)
|
||||
)
|
||||
}
|
||||
|
||||
/// 获取相册文件夹列表。
|
||||
func albumFolderList(
|
||||
scenicId: Int,
|
||||
|
||||
Reference in New Issue
Block a user