diff --git a/src/routes/production/storyboard/batchAddStoryboardInfo.ts b/src/routes/production/storyboard/batchAddStoryboardInfo.ts index 6222355..56f334b 100644 --- a/src/routes/production/storyboard/batchAddStoryboardInfo.ts +++ b/src/routes/production/storyboard/batchAddStoryboardInfo.ts @@ -91,7 +91,7 @@ export default router.post( const storyboardData = await Promise.all( lastStoryboard.map(async (i) => { return { - associateAssetsIds: await u.db("o_assets2Storyboard").where("storyboardId", i.id).select("assetId").pluck("assetId"), + associateAssetsIds: await u.db("o_assets2Storyboard").where("storyboardId", i.id).orderBy("rowid").select("assetId").pluck("assetId"), src: i.filePath ? await u.oss.getFileUrl(i.filePath) : "", id: i.id, trackId: i.trackId, diff --git a/src/routes/production/storyboard/batchGenerateImage.ts b/src/routes/production/storyboard/batchGenerateImage.ts index 743e1a3..2ed9cb7 100644 --- a/src/routes/production/storyboard/batchGenerateImage.ts +++ b/src/routes/production/storyboard/batchGenerateImage.ts @@ -50,18 +50,33 @@ export default router.post( const projectSettingData = await u.db("o_project").where("id", projectId).select("imageModel", "imageQuality", "artStyle", "videoRatio").first(); const storyboardData = await u.db("o_storyboard").where("scriptId", scriptId).whereIn("id", finalStoryboardIds); - const assetData = await u - .db("o_assets") - .leftJoin("o_assets2Storyboard", "o_assets.id", "o_assets2Storyboard.assetId") - .whereIn("o_assets2Storyboard.storyboardId", finalStoryboardIds) - .select("o_assets2Storyboard.storyboardId", "o_assets.imageId"); + // 按 rowid 顺序查出每个 storyboard 关联的 assetId 有序列表 + const assets2StoryboardRows = await u + .db("o_assets2Storyboard") + .whereIn("storyboardId", finalStoryboardIds) + .orderBy("rowid") + .select("storyboardId", "assetId"); + // 收集所有 assetId,批量查对应的 imageId + const allAssetIds = [...new Set(assets2StoryboardRows.map((r: any) => r.assetId))]; + const assetImageMap: Record = {}; + if (allAssetIds.length > 0) { + const assetRows = await u.db("o_assets").whereIn("id", allAssetIds).select("id", "imageId"); + assetRows.forEach((row: any) => { + assetImageMap[row.id] = row.imageId; + }); + } + + // 按 rowid 顺序重建 assetRecord,值为有序的 imageId 列表 const assetRecord: Record = {}; - assetData.forEach((item: any) => { + assets2StoryboardRows.forEach((item: any) => { if (!assetRecord[item.storyboardId]) { assetRecord[item.storyboardId] = []; } - assetRecord[item.storyboardId].push(item.imageId); + const imageId = assetImageMap[item.assetId]; + if (imageId != null) { + assetRecord[item.storyboardId].push(imageId); + } }); res.status(200).send( diff --git a/src/routes/production/workbench/generateVideoPrompt.ts b/src/routes/production/workbench/generateVideoPrompt.ts index 474444a..7f5dce7 100644 --- a/src/routes/production/workbench/generateVideoPrompt.ts +++ b/src/routes/production/workbench/generateVideoPrompt.ts @@ -32,7 +32,7 @@ export default router.post( .select("videoDesc", "prompt", "track", "duration", "shouldGenerateImage") .first(); // 查询分镜关联的资产ID - const assetRows = await u.db("o_assets2Storyboard").where("storyboardId", item.id).select("assetId"); + const assetRows = await u.db("o_assets2Storyboard").where("storyboardId", item.id).orderBy("rowid").select("assetId"); const associateAssetsIds = assetRows.map((row: any) => row.assetId); return { ...storyboard, @@ -91,6 +91,7 @@ export default router.post( (i) => ``, )}, `; diff --git a/src/types/database.d.ts b/src/types/database.d.ts index 551db81..09889b1 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -1,4 +1,4 @@ -// @db-hash 9248d7bcfe0a1bc57e5b9bc33d8c7d83 +// @db-hash 8669d907d827a8f55da1f1724d7ece06 //该文件由脚本自动生成,请勿手动修改 export interface memories { @@ -201,6 +201,7 @@ export interface o_user { 'password'?: string | null; } export interface o_vendorConfig { + 'code'?: string | null; 'enable'?: number | null; 'id'?: string; 'inputValues'?: string | null;