no message
This commit is contained in:
parent
c146edaf69
commit
1842fe74a8
@ -451,6 +451,7 @@ description: 专注于从剧本内容中提取所使用的资产(角色、场
|
|||||||
table.integer("imageId").unsigned().references("id").inTable("o_image");
|
table.integer("imageId").unsigned().references("id").inTable("o_image");
|
||||||
table.integer("assetsId");
|
table.integer("assetsId");
|
||||||
table.integer("projectId");
|
table.integer("projectId");
|
||||||
|
table.integer("flowId"); //工作流id
|
||||||
table.integer("startTime");
|
table.integer("startTime");
|
||||||
table.string("promptState");
|
table.string("promptState");
|
||||||
table.primary(["id"]);
|
table.primary(["id"]);
|
||||||
@ -487,6 +488,7 @@ description: 专注于从剧本内容中提取所使用的资产(角色、场
|
|||||||
table.integer("trackId");
|
table.integer("trackId");
|
||||||
table.text("reason");
|
table.text("reason");
|
||||||
table.integer("projectId");
|
table.integer("projectId");
|
||||||
|
table.integer("flowId"); //工作流id
|
||||||
table.integer("index");
|
table.integer("index");
|
||||||
table.integer("createTime");
|
table.integer("createTime");
|
||||||
table.primary(["id"]);
|
table.primary(["id"]);
|
||||||
@ -560,8 +562,6 @@ description: 专注于从剧本内容中提取所使用的资产(角色、场
|
|||||||
builder: (table) => {
|
builder: (table) => {
|
||||||
table.integer("id").notNullable();
|
table.integer("id").notNullable();
|
||||||
table.text("flowData").notNullable();
|
table.text("flowData").notNullable();
|
||||||
table.integer("storyboardId");
|
|
||||||
table.integer("assetsId");
|
|
||||||
table.primary(["id"]);
|
table.primary(["id"]);
|
||||||
table.unique(["id"]);
|
table.unique(["id"]);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -107,89 +107,41 @@ export default router.post(
|
|||||||
assets2StoryboardMap[i.storyboardId!].push(i.assetId!);
|
assets2StoryboardMap[i.storyboardId!].push(i.assetId!);
|
||||||
});
|
});
|
||||||
const flowData = JSON.parse(sqlData!.data ?? "{}");
|
const flowData = JSON.parse(sqlData!.data ?? "{}");
|
||||||
// 将原有 flowData.assets 按 id 建立索引,以便后续合并保留旧字段
|
|
||||||
const existingAssetsMap: Record<number, any> = {};
|
|
||||||
if (Array.isArray(flowData.assets)) {
|
|
||||||
flowData.assets.forEach((a: any) => {
|
|
||||||
existingAssetsMap[a.id] = a;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
flowData.assets = await Promise.all(
|
flowData.assets = await Promise.all(
|
||||||
assetsData.map(async (item) => {
|
assetsData.map(async (item) => ({
|
||||||
const existing = existingAssetsMap[item.id] ?? {};
|
id: item.id,
|
||||||
// 将原有 derive 按 id 建立索引
|
name: item.name ?? "",
|
||||||
const existingDeriveMap: Record<number, any> = {};
|
type: item.type ?? "",
|
||||||
if (Array.isArray(existing.derive)) {
|
prompt: item.prompt ?? "",
|
||||||
existing.derive.forEach((d: any) => {
|
desc: item.describe ?? "",
|
||||||
existingDeriveMap[d.id] = d;
|
src: item.filePath && (await u.oss.getFileUrl(item.filePath!)),
|
||||||
});
|
derive: await Promise.all(
|
||||||
}
|
childAssetsData
|
||||||
return {
|
.filter((child) => child.assetsId === item.id)
|
||||||
...existing,
|
.map(async (child) => ({
|
||||||
id: item.id,
|
id: child.id,
|
||||||
name: item.name ?? "",
|
assetsId: item.id,
|
||||||
type: item.type ?? "",
|
name: child.name ?? "",
|
||||||
prompt: item.prompt ?? "",
|
prompt: child.prompt,
|
||||||
desc: item.describe ?? "",
|
type: child.type,
|
||||||
src: item.filePath && (await u.oss.getFileUrl(item.filePath!)),
|
desc: child.describe ?? "",
|
||||||
derive: await Promise.all(
|
src: child.filePath && (await u.oss.getFileUrl(child.filePath!)),
|
||||||
childAssetsData
|
state: child.state ?? "未生成",
|
||||||
.filter((child) => child.assetsId === item.id)
|
})),
|
||||||
.map(async (child) => ({
|
),
|
||||||
...(existingDeriveMap[child.id] ?? {}),
|
})),
|
||||||
id: child.id,
|
|
||||||
assetsId: item.id,
|
|
||||||
name: child.name ?? "",
|
|
||||||
prompt: child.prompt,
|
|
||||||
type: child.type,
|
|
||||||
desc: child.describe ?? "",
|
|
||||||
src: child.filePath && (await u.oss.getFileUrl(child.filePath!)),
|
|
||||||
state: child.state ?? "未生成", //todo:矫正状态值
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
// 将数据库 storyboardData 按 id 建立索引
|
flowData.storyboard = storyboardData
|
||||||
const dbStoryboardMap: Record<number, (typeof storyboardData)[number]> = {};
|
.map((i) => ({
|
||||||
storyboardData.forEach((i) => {
|
id: i.id,
|
||||||
dbStoryboardMap[i.id!] = i;
|
index: i.index,
|
||||||
});
|
duration: i.duration ? +i.duration : 0,
|
||||||
|
prompt: i.prompt,
|
||||||
// 用于构造单条 storyboard 的辅助函数
|
associateAssetsIds: assets2StoryboardMap[i.id!] ?? [],
|
||||||
const buildStoryboardItem = (i: (typeof storyboardData)[number], existing: any = {}) => ({
|
src: i.filePath,
|
||||||
...existing,
|
state: i.state,
|
||||||
id: i.id,
|
}))
|
||||||
index: i.index,
|
.sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
|
||||||
duration: i.duration ? +i.duration : 0,
|
|
||||||
prompt: i.prompt,
|
|
||||||
associateAssetsIds: assets2StoryboardMap[i.id!] ?? [],
|
|
||||||
src: i.filePath,
|
|
||||||
state: i.state,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 保持旧数据顺序,新增的追加到最后
|
|
||||||
const usedIds = new Set<number>();
|
|
||||||
const orderedStoryboard: any[] = [];
|
|
||||||
|
|
||||||
// 1. 按旧数据顺序遍历,若数据库中仍存在则合并更新
|
|
||||||
if (Array.isArray(flowData.storyboard)) {
|
|
||||||
flowData.storyboard.forEach((s: any) => {
|
|
||||||
const dbItem = dbStoryboardMap[s.id];
|
|
||||||
if (dbItem) {
|
|
||||||
orderedStoryboard.push(buildStoryboardItem(dbItem, s));
|
|
||||||
usedIds.add(s.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 数据库中新增的(旧数据中没有的)追加到最后
|
|
||||||
storyboardData.forEach((i) => {
|
|
||||||
if (!usedIds.has(i.id!)) {
|
|
||||||
orderedStoryboard.push(buildStoryboardItem(i));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
flowData.storyboard = orderedStoryboard.sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
|
|
||||||
res.status(200).send(success(flowData));
|
res.status(200).send(success(flowData));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(400).send(error());
|
res.status(400).send(error());
|
||||||
|
|||||||
@ -24,17 +24,14 @@ export default router.post(
|
|||||||
episodesId: number;
|
episodesId: number;
|
||||||
} = req.body;
|
} = req.body;
|
||||||
const sqlData = await u.db("o_agentWorkData").where("projectId", String(projectId)).andWhere("episodesId", String(episodesId)).first();
|
const sqlData = await u.db("o_agentWorkData").where("projectId", String(projectId)).andWhere("episodesId", String(episodesId)).first();
|
||||||
// if (data.storyboard && data.storyboard.length)
|
if (data.storyboard && data.storyboard.length)
|
||||||
// await Promise.all(
|
await Promise.all(
|
||||||
// data.storyboard.map(async (i, index) => {
|
data.storyboard.map(async (i, index) => {
|
||||||
// await u
|
await u.db("o_storyboard").where("id", i.id).update({
|
||||||
// .db("o_storyboard")
|
index: index,
|
||||||
// .where("id", i.id)
|
});
|
||||||
// .update({
|
}),
|
||||||
// index: index + 1,
|
);
|
||||||
// });
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
if (!sqlData) {
|
if (!sqlData) {
|
||||||
await u.db("o_agentWorkData").insert({
|
await u.db("o_agentWorkData").insert({
|
||||||
projectId,
|
projectId,
|
||||||
|
|||||||
89
src/types/database.d.ts
vendored
89
src/types/database.d.ts
vendored
@ -1,19 +1,48 @@
|
|||||||
// @db-hash b1210691844e077e9df7dc16c802ce5a
|
// @db-hash c145f43374602285beea82bbd51eaec8
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
export interface _o_project_old_20260331 {
|
export interface _o_storyboard_old_20260331 {
|
||||||
'artStyle'?: string | null;
|
'camera'?: string | null;
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
'id'?: number | null;
|
'description'?: string | null;
|
||||||
'imageModel'?: string | null;
|
'duration'?: string | null;
|
||||||
'imageQuality'?: string | null;
|
'filePath'?: string | null;
|
||||||
'intro'?: string | null;
|
'frameMode'?: string | null;
|
||||||
'name'?: string | null;
|
'id'?: number;
|
||||||
'projectType'?: string | null;
|
'index'?: number | null;
|
||||||
'type'?: string | null;
|
'lines'?: string | null;
|
||||||
'userId'?: number | null;
|
'mode'?: string | null;
|
||||||
'videoModel'?: string | null;
|
'model'?: string | null;
|
||||||
'videoRatio'?: string | null;
|
'prompt'?: string | null;
|
||||||
|
'reason'?: string | null;
|
||||||
|
'resolution'?: string | null;
|
||||||
|
'scriptId'?: number | null;
|
||||||
|
'sound'?: string | null;
|
||||||
|
'state'?: string | null;
|
||||||
|
'title'?: string | null;
|
||||||
|
'videoPrompt'?: string | null;
|
||||||
|
}
|
||||||
|
export interface _o_storyboard_old_20260331_1 {
|
||||||
|
'camera'?: string | null;
|
||||||
|
'createTime'?: number | null;
|
||||||
|
'description'?: string | null;
|
||||||
|
'duration'?: string | null;
|
||||||
|
'filePath'?: string | null;
|
||||||
|
'frameMode'?: string | null;
|
||||||
|
'id'?: number;
|
||||||
|
'index'?: number | null;
|
||||||
|
'lines'?: string | null;
|
||||||
|
'mode'?: string | null;
|
||||||
|
'model'?: string | null;
|
||||||
|
'prompt'?: string | null;
|
||||||
|
'reason'?: string | null;
|
||||||
|
'resolution'?: string | null;
|
||||||
|
'scriptId'?: number | null;
|
||||||
|
'sound'?: string | null;
|
||||||
|
'state'?: string | null;
|
||||||
|
'title'?: string | null;
|
||||||
|
'track'?: string | null;
|
||||||
|
'videoPrompt'?: string | null;
|
||||||
}
|
}
|
||||||
export interface memories {
|
export interface memories {
|
||||||
'content': string;
|
'content': string;
|
||||||
@ -87,6 +116,7 @@ export interface o_image {
|
|||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'model'?: string | null;
|
'model'?: string | null;
|
||||||
|
'reason'?: string | null;
|
||||||
'resolution'?: string | null;
|
'resolution'?: string | null;
|
||||||
'state'?: string | null;
|
'state'?: string | null;
|
||||||
'type'?: string | null;
|
'type'?: string | null;
|
||||||
@ -127,7 +157,6 @@ export interface o_project {
|
|||||||
'imageModel'?: string | null;
|
'imageModel'?: string | null;
|
||||||
'imageQuality'?: string | null;
|
'imageQuality'?: string | null;
|
||||||
'intro'?: string | null;
|
'intro'?: string | null;
|
||||||
'mode'?: string | null;
|
|
||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'projectType'?: string | null;
|
'projectType'?: string | null;
|
||||||
'type'?: string | null;
|
'type'?: string | null;
|
||||||
@ -175,25 +204,17 @@ export interface o_skillList {
|
|||||||
'updateTime': number;
|
'updateTime': number;
|
||||||
}
|
}
|
||||||
export interface o_storyboard {
|
export interface o_storyboard {
|
||||||
'camera'?: string | null;
|
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
'description'?: string | null;
|
|
||||||
'duration'?: string | null;
|
'duration'?: string | null;
|
||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'frameMode'?: string | null;
|
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'index'?: number | null;
|
'index'?: number | null;
|
||||||
'lines'?: string | null;
|
'projectId'?: number | null;
|
||||||
'mode'?: string | null;
|
|
||||||
'model'?: string | null;
|
|
||||||
'prompt'?: string | null;
|
'prompt'?: string | null;
|
||||||
'reason'?: string | null;
|
'reason'?: string | null;
|
||||||
'resolution'?: string | null;
|
|
||||||
'scriptId'?: number | null;
|
'scriptId'?: number | null;
|
||||||
'sound'?: string | null;
|
|
||||||
'state'?: string | null;
|
'state'?: string | null;
|
||||||
'title'?: string | null;
|
'trackId'?: number | null;
|
||||||
'videoPrompt'?: string | null;
|
|
||||||
}
|
}
|
||||||
export interface o_tasks {
|
export interface o_tasks {
|
||||||
'describe'?: string | null;
|
'describe'?: string | null;
|
||||||
@ -230,8 +251,22 @@ export interface o_video {
|
|||||||
'projectId'?: number | null;
|
'projectId'?: number | null;
|
||||||
'scriptId'?: number | null;
|
'scriptId'?: number | null;
|
||||||
'state'?: string | null;
|
'state'?: string | null;
|
||||||
|
'storyboardId'?: number | null;
|
||||||
'time'?: number | null;
|
'time'?: number | null;
|
||||||
'videoTrackId'?: number | null;
|
}
|
||||||
|
export interface o_videoConfig {
|
||||||
|
'audio'?: number | null;
|
||||||
|
'createTime'?: number | null;
|
||||||
|
'data'?: string | null;
|
||||||
|
'duration'?: number | null;
|
||||||
|
'id'?: number;
|
||||||
|
'mode'?: string | null;
|
||||||
|
'model'?: string | null;
|
||||||
|
'prompt'?: string | null;
|
||||||
|
'resolution'?: string | null;
|
||||||
|
'storyboardId'?: number | null;
|
||||||
|
'updateTime'?: number | null;
|
||||||
|
'videoId'?: number | null;
|
||||||
}
|
}
|
||||||
export interface o_videoTrack {
|
export interface o_videoTrack {
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
@ -241,7 +276,8 @@ export interface o_videoTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
"_o_project_old_20260331": _o_project_old_20260331;
|
"_o_storyboard_old_20260331": _o_storyboard_old_20260331;
|
||||||
|
"_o_storyboard_old_20260331_1": _o_storyboard_old_20260331_1;
|
||||||
"memories": memories;
|
"memories": memories;
|
||||||
"o_agentDeploy": o_agentDeploy;
|
"o_agentDeploy": o_agentDeploy;
|
||||||
"o_agentWorkData": o_agentWorkData;
|
"o_agentWorkData": o_agentWorkData;
|
||||||
@ -267,5 +303,6 @@ export interface DB {
|
|||||||
"o_user": o_user;
|
"o_user": o_user;
|
||||||
"o_vendorConfig": o_vendorConfig;
|
"o_vendorConfig": o_vendorConfig;
|
||||||
"o_video": o_video;
|
"o_video": o_video;
|
||||||
|
"o_videoConfig": o_videoConfig;
|
||||||
"o_videoTrack": o_videoTrack;
|
"o_videoTrack": o_videoTrack;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user