添加资产生成失败原因
This commit is contained in:
parent
7c10411c15
commit
2e4f78eae1
@ -453,6 +453,7 @@ description: 专注于从剧本内容中提取所使用的资产(角色、场
|
|||||||
table.integer("projectId");
|
table.integer("projectId");
|
||||||
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"]);
|
||||||
},
|
},
|
||||||
@ -469,6 +470,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"]);
|
||||||
|
|||||||
@ -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");
|
||||||
|
|||||||
@ -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 });
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -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 }));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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 || "图片生成失败"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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 ?? "生成失败"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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");
|
||||||
|
|||||||
29
src/types/database.d.ts
vendored
29
src/types/database.d.ts
vendored
@ -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 {
|
export interface _o_project_old_20260331 {
|
||||||
'artStyle'?: string | null;
|
'artStyle'?: string | null;
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
@ -61,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;
|
||||||
@ -84,6 +108,7 @@ 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;
|
||||||
@ -241,6 +266,8 @@ export interface o_videoTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
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;
|
"_o_project_old_20260331": _o_project_old_20260331;
|
||||||
"memories": memories;
|
"memories": memories;
|
||||||
"o_agentDeploy": o_agentDeploy;
|
"o_agentDeploy": o_agentDeploy;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user