diff --git a/src/routes/assets/getMaterialData.ts b/src/routes/assets/getMaterialData.ts index e269bd8..8c35c07 100644 --- a/src/routes/assets/getMaterialData.ts +++ b/src/routes/assets/getMaterialData.ts @@ -18,8 +18,7 @@ export default router.post( .db("o_assets") .leftJoin("o_image", "o_assets.id", "=", "o_image.assetsId") .where("o_assets.type", "clip") - .andWhere("projectId", projectId) - .andWhere("scriptId", scriptId) + .andWhere("o_assets.projectId", projectId) .select("*"); const data = await Promise.all( list.map(async (item) => ({ @@ -35,16 +34,30 @@ export default router.post( filePath: ending, type: "clip", }); - // 查询o_video表 - const videoRows = await u.db("o_video").where("state", "生成成功").andWhere("scriptId", scriptId).andWhere("projectId", projectId).select("*"); - // 处理并返回结果 + // 查询视频轨道 + const trackRows = await u + .db("o_videoTrack") + .where("o_videoTrack.scriptId", scriptId) + .andWhere("o_videoTrack.projectId", projectId) + .select("o_videoTrack.id as trackId","o_videoTrack.videoId"); + // 按轨道分组处理视频 const video = await Promise.all( - videoRows.map(async (row) => ({ - id: row.id, - filePath: row.filePath ? await u.oss.getFileUrl(row.filePath) : "", - videoTrackId: row.videoTrackId, - })), - ); + trackRows.map(async (track) => { + const videoItems = await u.db("o_video").where("o_video.videoTrackId", track.trackId).andWhere("o_video.state", "生成成功").select("*"); + const videoList = await Promise.all( + videoItems.map(async (v) => ({ + id: v.id, + filePath: v.filePath ? await u.oss.getFileUrl(v.filePath) : "", + videoTrackId: v.videoTrackId, + })), + ); + return { + id: track.trackId, + videoId: track.videoId, + video: videoList, + }; + }), + ).then((tracks) => tracks.filter((track) => track.video.length > 0)); res.status(200).send(success({ data, video })); }, diff --git a/src/routes/production/workbench/deleteTrack.ts b/src/routes/production/workbench/deleteTrack.ts index 5541175..e309525 100644 --- a/src/routes/production/workbench/deleteTrack.ts +++ b/src/routes/production/workbench/deleteTrack.ts @@ -13,7 +13,6 @@ export default router.post( async (req, res) => { const { id } = req.body; await u.db("o_videoTrack").where("id", id).delete(); - await u.db("o_storyboard").where("trackId", id).delete(); res.status(200).send(success({ message: "视频段删除成功" })); }, ); diff --git a/src/types/database.d.ts b/src/types/database.d.ts index a787e02..8adea86 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -1,6 +1,37 @@ -// @db-hash 71e339c0a728c10bedb294a93976dcd8 +// @db-hash 6cd709d9bdfe00c4dc87961a8ebba149 //该文件由脚本自动生成,请勿手动修改 +export interface _o_project_old_20260404 { + 'artStyle'?: string | null; + 'createTime'?: number | null; + 'directorManual'?: string | null; + 'id'?: number | null; + 'imageModel'?: string | null; + 'imageQuality'?: string | null; + 'intro'?: string | null; + 'mode'?: string | null; + 'name'?: string | null; + 'projectType'?: string | null; + 'type'?: string | null; + 'userId'?: number | null; + 'videoModel'?: string | null; + 'videoRatio'?: string | null; +} +export interface _o_prompt_old_20260406 { + 'data'?: string | null; + 'id'?: number; + 'name'?: string | null; + 'type'?: string | null; + 'useData'?: string | null; +} +export interface _o_prompt_old_20260406_1 { + 'data'?: string | null; + 'id'?: number; + 'name'?: string | null; + 'TEXT'?: any | null; + 'type'?: string | null; + 'useData'?: string | null; +} export interface memories { 'content': string; 'createTime': number; @@ -59,10 +90,6 @@ export interface o_assets2Storyboard { 'assetId'?: number; 'storyboardId'?: number; } -export interface o_assetsRole2Audio { - 'assetsAudioId'?: number; - 'assetsRoleId'?: number; -} export interface o_event { 'createTime'?: number | null; 'detail'?: string | null; @@ -236,13 +263,15 @@ export interface o_videoTrack { } export interface DB { + "_o_project_old_20260404": _o_project_old_20260404; + "_o_prompt_old_20260406": _o_prompt_old_20260406; + "_o_prompt_old_20260406_1": _o_prompt_old_20260406_1; "memories": memories; "o_agentDeploy": o_agentDeploy; "o_agentWorkData": o_agentWorkData; "o_artStyle": o_artStyle; "o_assets": o_assets; "o_assets2Storyboard": o_assets2Storyboard; - "o_assetsRole2Audio": o_assetsRole2Audio; "o_event": o_event; "o_eventChapter": o_eventChapter; "o_image": o_image;