添加资产生成失败原因

This commit is contained in:
小帅 2026-03-31 22:46:17 +08:00
parent 7c10411c15
commit 2e4f78eae1
8 changed files with 53 additions and 8 deletions

View File

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

View File

@ -34,7 +34,7 @@ export default router.post(
let childQuery = u
.db("o_assets")
.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)
.andWhere("o_assets.type", type)
.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 });
} 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: "已完成" });
} 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 }));
},

View File

@ -134,7 +134,10 @@ export default router.post("/", validateFields(requestSchema), async (req, res)
return res.status(200).send(success({ path, assetsId: id }));
} 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 || "图片生成失败"));
}
});

View File

@ -110,6 +110,10 @@ export default router.post(
res.status(200).send(success({ prompt: _output, assetsId }));
} 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 ?? "生成失败"));
}
},

View File

@ -16,12 +16,13 @@ export default router.post(
const data = await u
.db("o_assets")
.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)
.andWhere("o_assets.type", "<>", "clip")
.modify((qb) => {
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(
data.map(async (parent: any) => {
const historyImages = await u.db("o_image").where("assetsId", parent.id).andWhere("state", "已完成").select("id", "filePath");

View File

@ -1,6 +1,29 @@
// @db-hash b1210691844e077e9df7dc16c802ce5a
// @db-hash 4789feeeda48b86ecadc17318a89460b
//该文件由脚本自动生成,请勿手动修改
export interface _o_assets_old_20260331 {
'assetsId'?: number | null;
'describe'?: string | null;
'id'?: number;
'imageId'?: number | null;
'name'?: string | null;
'projectId'?: number | null;
'prompt'?: string | null;
'promptState'?: string | null;
'remark'?: string | null;
'scriptId'?: number | null;
'startTime'?: number | null;
'type'?: string | null;
}
export interface _o_image_old_20260331 {
'assetsId'?: number | null;
'filePath'?: string | null;
'id'?: number;
'model'?: string | null;
'resolution'?: string | null;
'state'?: string | null;
'type'?: string | null;
}
export interface _o_project_old_20260331 {
'artStyle'?: string | null;
'createTime'?: number | null;
@ -61,6 +84,7 @@ export interface o_assets {
'name'?: string | null;
'projectId'?: number | null;
'prompt'?: string | null;
'promptErrorReason'?: string | null;
'promptState'?: string | null;
'remark'?: string | null;
'scriptId'?: number | null;
@ -84,6 +108,7 @@ export interface o_eventChapter {
}
export interface o_image {
'assetsId'?: number | null;
'errorReason'?: string | null;
'filePath'?: string | null;
'id'?: number;
'model'?: string | null;
@ -241,6 +266,8 @@ export interface o_videoTrack {
}
export interface DB {
"_o_assets_old_20260331": _o_assets_old_20260331;
"_o_image_old_20260331": _o_image_old_20260331;
"_o_project_old_20260331": _o_project_old_20260331;
"memories": memories;
"o_agentDeploy": o_agentDeploy;