# Conflicts:
#	src/types/database.d.ts
This commit is contained in:
zhishi 2026-03-31 23:08:38 +08:00
commit 7422565a16
8 changed files with 70 additions and 62 deletions

View File

@ -454,6 +454,7 @@ description: 专注于从剧本内容中提取所使用的资产(角色、场
table.integer("flowId"); //工作流id table.integer("flowId"); //工作流id
table.integer("startTime"); table.integer("startTime");
table.string("promptState"); table.string("promptState");
table.text("promptErrorReason");
table.primary(["id"]); table.primary(["id"]);
table.unique(["id"]); table.unique(["id"]);
}, },
@ -470,6 +471,7 @@ description: 专注于从剧本内容中提取所使用的资产(角色、场
table.text("model"); table.text("model");
table.text("resolution"); table.text("resolution");
table.text("state"); table.text("state");
table.text("errorReason");
table.text("reason"); table.text("reason");
table.primary(["id"]); table.primary(["id"]);
table.unique(["id"]); table.unique(["id"]);

View File

@ -34,7 +34,7 @@ export default router.post(
let childQuery = u let childQuery = u
.db("o_assets") .db("o_assets")
.leftJoin("o_image", "o_assets.imageId", "o_image.id") .leftJoin("o_image", "o_assets.imageId", "o_image.id")
.select("o_assets.*", "o_image.filePath", "o_image.state") .select("o_assets.*", "o_image.filePath", "o_image.state", "o_image.errorReason")
.where("o_assets.projectId", projectId) .where("o_assets.projectId", projectId)
.andWhere("o_assets.type", type) .andWhere("o_assets.type", type)
.whereNotNull("o_assets.assetsId"); .whereNotNull("o_assets.assetsId");

View File

@ -142,7 +142,10 @@ export default router.post("/", validateFields(requestSchema), async (req, res)
await u.db("o_assets").where("id", item.id).update({ imageId }); await u.db("o_assets").where("id", item.id).update({ imageId });
} catch (e: any) { } catch (e: any) {
await u.db("o_image").where("id", imageId).update({ state: "生成失败" }); await u
.db("o_image")
.where("id", imageId)
.update({ state: "生成失败", errorReason: u.error(e).message });
} }
}), }),
); );

View File

@ -127,13 +127,18 @@ export default router.post(
await u.db("o_assets").where("id", item.assetsId).update({ prompt: _output, promptState: "已完成" }); await u.db("o_assets").where("id", item.assetsId).update({ prompt: _output, promptState: "已完成" });
} catch (e: any) { } catch (e: any) {
await u.db("o_assets").where("id", item.assetsId).update({ promptState: "生成失败" }); await u
.db("o_assets")
.where("id", item.assetsId)
.update({ promptState: "失败", promptErrorReason: u.error(e).message });
} }
}), }),
); );
// 后台执行,不等待结果 // 后台执行,不等待结果
Promise.all(tasks).catch(() => {}); Promise.all(tasks).catch((err: any) => {
res.status(500).send(error(err));
});
return res.status(200).send(success({ total: items.length })); return res.status(200).send(success({ total: items.length }));
}, },

View File

@ -134,7 +134,10 @@ export default router.post("/", validateFields(requestSchema), async (req, res)
return res.status(200).send(success({ path, assetsId: id })); return res.status(200).send(success({ path, assetsId: id }));
} catch (e) { } catch (e) {
await u.db("o_image").where("id", imageId).update({ state: "生成失败" }); await u
.db("o_image")
.where("id", imageId)
.update({ state: "生成失败", errorReason: u.error(e).message });
return res.status(400).send(error(u.error(e).message || "图片生成失败")); return res.status(400).send(error(u.error(e).message || "图片生成失败"));
} }
}); });

View File

@ -110,6 +110,10 @@ export default router.post(
res.status(200).send(success({ prompt: _output, assetsId })); res.status(200).send(success({ prompt: _output, assetsId }));
} catch (e: any) { } catch (e: any) {
await u
.db("o_assets")
.where("id", assetsId)
.update({ promptState: "失败", promptErrorReason: u.error(e).message });
return res.status(500).send(error(e?.data?.error?.message ?? e?.message ?? "生成失败")); return res.status(500).send(error(e?.data?.error?.message ?? e?.message ?? "生成失败"));
} }
}, },

View File

@ -16,12 +16,13 @@ export default router.post(
const data = await u const data = await u
.db("o_assets") .db("o_assets")
.leftJoin("o_image", "o_assets.imageId", "o_image.id") .leftJoin("o_image", "o_assets.imageId", "o_image.id")
.select("o_assets.*", "o_image.filePath", "o_image.state", "o_image.model", "o_image.resolution") .select("o_assets.*", "o_image.filePath", "o_image.state", "o_image.model", "o_image.resolution", "o_image.errorReason")
.where("o_assets.projectId", projectId) .where("o_assets.projectId", projectId)
.andWhere("o_assets.type", "<>", "clip") .andWhere("o_assets.type", "<>", "clip")
.modify((qb) => { .modify((qb) => {
if (type && type.length > 0) qb.whereIn("o_assets.type", type); if (type && type.length > 0) qb.whereIn("o_assets.type", type);
}).orderByRaw(`CASE o_assets.type WHEN 'role' THEN 1 WHEN 'scene' THEN 2 WHEN 'tool' THEN 3 ELSE 4 END`); })
.orderByRaw(`CASE o_assets.type WHEN 'role' THEN 1 WHEN 'scene' THEN 2 WHEN 'tool' THEN 3 ELSE 4 END`);
const result = await Promise.all( const result = await Promise.all(
data.map(async (parent: any) => { data.map(async (parent: any) => {
const historyImages = await u.db("o_image").where("assetsId", parent.id).andWhere("state", "已完成").select("id", "filePath"); const historyImages = await u.db("o_image").where("assetsId", parent.id).andWhere("state", "已完成").select("id", "filePath");

View File

@ -1,48 +1,42 @@
// @db-hash c145f43374602285beea82bbd51eaec8 // @db-hash 4789feeeda48b86ecadc17318a89460b
//该文件由脚本自动生成,请勿手动修改 //该文件由脚本自动生成,请勿手动修改
export interface _o_storyboard_old_20260331 { export interface _o_assets_old_20260331 {
'camera'?: string | null; 'assetsId'?: number | null;
'createTime'?: number | null; 'describe'?: string | null;
'description'?: string | null;
'duration'?: string | null;
'filePath'?: string | null;
'frameMode'?: string | null;
'id'?: number; 'id'?: number;
'index'?: number | null; 'imageId'?: number | null;
'lines'?: string | null; 'name'?: string | null;
'mode'?: string | null; 'projectId'?: number | null;
'model'?: string | null;
'prompt'?: string | null; 'prompt'?: string | null;
'reason'?: string | null; 'promptState'?: string | null;
'resolution'?: string | null; 'remark'?: string | null;
'scriptId'?: number | null; 'scriptId'?: number | null;
'sound'?: string | null; 'startTime'?: number | null;
'state'?: string | null; 'type'?: string | null;
'title'?: string | null;
'videoPrompt'?: string | null;
} }
export interface _o_storyboard_old_20260331_1 { export interface _o_image_old_20260331 {
'camera'?: string | null; 'assetsId'?: number | null;
'createTime'?: number | null;
'description'?: string | null;
'duration'?: string | null;
'filePath'?: string | null; 'filePath'?: string | null;
'frameMode'?: string | null;
'id'?: number; 'id'?: number;
'index'?: number | null;
'lines'?: string | null;
'mode'?: string | null;
'model'?: string | null; 'model'?: string | null;
'prompt'?: string | null;
'reason'?: string | null;
'resolution'?: string | null; 'resolution'?: string | null;
'scriptId'?: number | null;
'sound'?: string | null;
'state'?: string | null; 'state'?: string | null;
'title'?: string | null; 'type'?: string | null;
'track'?: string | null; }
'videoPrompt'?: string | null; export interface _o_project_old_20260331 {
'artStyle'?: string | null;
'createTime'?: number | null;
'id'?: number | null;
'imageModel'?: string | null;
'imageQuality'?: string | null;
'intro'?: string | null;
'name'?: string | null;
'projectType'?: string | null;
'type'?: string | null;
'userId'?: number | null;
'videoModel'?: string | null;
'videoRatio'?: string | null;
} }
export interface memories { export interface memories {
'content': string; 'content': string;
@ -90,6 +84,7 @@ export interface o_assets {
'name'?: string | null; 'name'?: string | null;
'projectId'?: number | null; 'projectId'?: number | null;
'prompt'?: string | null; 'prompt'?: string | null;
'promptErrorReason'?: string | null;
'promptState'?: string | null; 'promptState'?: string | null;
'remark'?: string | null; 'remark'?: string | null;
'scriptId'?: number | null; 'scriptId'?: number | null;
@ -113,10 +108,10 @@ export interface o_eventChapter {
} }
export interface o_image { export interface o_image {
'assetsId'?: number | null; 'assetsId'?: number | null;
'errorReason'?: string | null;
'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;
@ -157,6 +152,7 @@ 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;
@ -204,17 +200,25 @@ 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;
'projectId'?: number | null; 'lines'?: string | 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;
'trackId'?: number | null; 'title'?: string | null;
'videoPrompt'?: string | null;
} }
export interface o_tasks { export interface o_tasks {
'describe'?: string | null; 'describe'?: string | null;
@ -251,22 +255,8 @@ 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;
@ -276,8 +266,9 @@ export interface o_videoTrack {
} }
export interface DB { export interface DB {
"_o_storyboard_old_20260331": _o_storyboard_old_20260331; "_o_assets_old_20260331": _o_assets_old_20260331;
"_o_storyboard_old_20260331_1": _o_storyboard_old_20260331_1; "_o_image_old_20260331": _o_image_old_20260331;
"_o_project_old_20260331": _o_project_old_20260331;
"memories": memories; "memories": memories;
"o_agentDeploy": o_agentDeploy; "o_agentDeploy": o_agentDeploy;
"o_agentWorkData": o_agentWorkData; "o_agentWorkData": o_agentWorkData;
@ -303,6 +294,5 @@ 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;
} }