修复bug
This commit is contained in:
parent
24a7376d8a
commit
6fde33aa09
@ -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,
|
||||
|
||||
@ -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<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[]> = {};
|
||||
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(
|
||||
|
||||
@ -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) => `<storyboardItem
|
||||
videoDesc='${i.videoDesc}'
|
||||
duration='${i.duration}'
|
||||
associateAssetsIds='${i.associateAssetsIds}'
|
||||
></storyboardItem>`,
|
||||
)},
|
||||
`;
|
||||
|
||||
3
src/types/database.d.ts
vendored
3
src/types/database.d.ts
vendored
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user