修复bug

This commit is contained in:
zhishi 2026-04-12 17:46:59 +08:00
parent 24a7376d8a
commit 6fde33aa09
4 changed files with 27 additions and 10 deletions

View File

@ -91,7 +91,7 @@ export default router.post(
const storyboardData = await Promise.all( const storyboardData = await Promise.all(
lastStoryboard.map(async (i) => { lastStoryboard.map(async (i) => {
return { 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) : "", src: i.filePath ? await u.oss.getFileUrl(i.filePath) : "",
id: i.id, id: i.id,
trackId: i.trackId, trackId: i.trackId,

View File

@ -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 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 storyboardData = await u.db("o_storyboard").where("scriptId", scriptId).whereIn("id", finalStoryboardIds);
const assetData = await u // 按 rowid 顺序查出每个 storyboard 关联的 assetId 有序列表
.db("o_assets") const assets2StoryboardRows = await u
.leftJoin("o_assets2Storyboard", "o_assets.id", "o_assets2Storyboard.assetId") .db("o_assets2Storyboard")
.whereIn("o_assets2Storyboard.storyboardId", finalStoryboardIds) .whereIn("storyboardId", finalStoryboardIds)
.select("o_assets2Storyboard.storyboardId", "o_assets.imageId"); .orderBy("rowid")
.select("storyboardId", "assetId");
// 收集所有 assetId批量查对应的 imageId
const allAssetIds = [...new Set(assets2StoryboardRows.map((r: any) => r.assetId))];
const assetImageMap: Record<number, number> = {};
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<number, number[]> = {}; const assetRecord: Record<number, number[]> = {};
assetData.forEach((item: any) => { assets2StoryboardRows.forEach((item: any) => {
if (!assetRecord[item.storyboardId]) { if (!assetRecord[item.storyboardId]) {
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( res.status(200).send(

View File

@ -32,7 +32,7 @@ export default router.post(
.select("videoDesc", "prompt", "track", "duration", "shouldGenerateImage") .select("videoDesc", "prompt", "track", "duration", "shouldGenerateImage")
.first(); .first();
// 查询分镜关联的资产ID // 查询分镜关联的资产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); const associateAssetsIds = assetRows.map((row: any) => row.assetId);
return { return {
...storyboard, ...storyboard,
@ -91,6 +91,7 @@ export default router.post(
(i) => `<storyboardItem (i) => `<storyboardItem
videoDesc='${i.videoDesc}' videoDesc='${i.videoDesc}'
duration='${i.duration}' duration='${i.duration}'
associateAssetsIds='${i.associateAssetsIds}'
></storyboardItem>`, ></storyboardItem>`,
)}, )},
`; `;

View File

@ -1,4 +1,4 @@
// @db-hash 9248d7bcfe0a1bc57e5b9bc33d8c7d83 // @db-hash 8669d907d827a8f55da1f1724d7ece06
//该文件由脚本自动生成,请勿手动修改 //该文件由脚本自动生成,请勿手动修改
export interface memories { export interface memories {
@ -201,6 +201,7 @@ export interface o_user {
'password'?: string | null; 'password'?: string | null;
} }
export interface o_vendorConfig { export interface o_vendorConfig {
'code'?: string | null;
'enable'?: number | null; 'enable'?: number | null;
'id'?: string; 'id'?: string;
'inputValues'?: string | null; 'inputValues'?: string | null;