From 2e4f78eae15c4e39f363eca3f3f5923f29223174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B8=85?= <2944435683> Date: Tue, 31 Mar 2026 22:46:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B5=84=E4=BA=A7=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=A4=B1=E8=B4=A5=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/initDB.ts | 2 ++ src/routes/assets/getAssetsApi.ts | 2 +- .../batchGenerateImageAssets.ts | 5 +++- .../assetsGenerate/batchPolishAssetsPrompt.ts | 9 ++++-- src/routes/assetsGenerate/generateAssets.ts | 5 +++- .../assetsGenerate/polishAssetsPrompt.ts | 4 +++ src/routes/cornerScape/getAllAssets.ts | 5 ++-- src/types/database.d.ts | 29 ++++++++++++++++++- 8 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/lib/initDB.ts b/src/lib/initDB.ts index cf28c09..c66a7e2 100644 --- a/src/lib/initDB.ts +++ b/src/lib/initDB.ts @@ -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"]); diff --git a/src/routes/assets/getAssetsApi.ts b/src/routes/assets/getAssetsApi.ts index 8910fbe..c3d95b1 100644 --- a/src/routes/assets/getAssetsApi.ts +++ b/src/routes/assets/getAssetsApi.ts @@ -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"); diff --git a/src/routes/assetsGenerate/batchGenerateImageAssets.ts b/src/routes/assetsGenerate/batchGenerateImageAssets.ts index 55e4e30..9cd1094 100644 --- a/src/routes/assetsGenerate/batchGenerateImageAssets.ts +++ b/src/routes/assetsGenerate/batchGenerateImageAssets.ts @@ -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 }); } }), ); diff --git a/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts b/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts index 1738e99..72c9c07 100644 --- a/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts +++ b/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts @@ -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 })); }, diff --git a/src/routes/assetsGenerate/generateAssets.ts b/src/routes/assetsGenerate/generateAssets.ts index 830c536..1c32f5d 100644 --- a/src/routes/assetsGenerate/generateAssets.ts +++ b/src/routes/assetsGenerate/generateAssets.ts @@ -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 || "图片生成失败")); } }); diff --git a/src/routes/assetsGenerate/polishAssetsPrompt.ts b/src/routes/assetsGenerate/polishAssetsPrompt.ts index c02decc..438af1e 100644 --- a/src/routes/assetsGenerate/polishAssetsPrompt.ts +++ b/src/routes/assetsGenerate/polishAssetsPrompt.ts @@ -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 ?? "生成失败")); } }, diff --git a/src/routes/cornerScape/getAllAssets.ts b/src/routes/cornerScape/getAllAssets.ts index ef4ce0a..83620a1 100644 --- a/src/routes/cornerScape/getAllAssets.ts +++ b/src/routes/cornerScape/getAllAssets.ts @@ -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"); diff --git a/src/types/database.d.ts b/src/types/database.d.ts index 9c19252..d72b0fc 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -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;