From 5e826586db87419a523e34921acf8b7570d75dc5 Mon Sep 17 00:00:00 2001 From: zhishi <1951671751@qq.com> Date: Tue, 14 Apr 2026 11:39:00 +0800 Subject: [PATCH] no message --- src/routes/production/workbench/getFileUrl.ts | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/routes/production/workbench/getFileUrl.ts b/src/routes/production/workbench/getFileUrl.ts index 495e26b..4119c1f 100644 --- a/src/routes/production/workbench/getFileUrl.ts +++ b/src/routes/production/workbench/getFileUrl.ts @@ -9,14 +9,31 @@ const router = express.Router(); export default router.post( "/", validateFields({ - paths: z.array(z.string()) + items: z.array(z.object({ + id: z.number(), + sources: z.string() + })) }), async (req, res) => { - const { paths } = req.body; + const { items } = req.body; const result: Record = {}; + const storyboardIds = items.filter((item: any) => item.sources == "storyboard").map((item: any) => item.id) + const totalFilePaths = [] + if (storyboardIds.length) { + const storyBoardPaths = await u.db("o_storyboard").whereIn("id", storyboardIds).select("id", "filePath"); + totalFilePaths.push(...storyBoardPaths.map(i => ({ id: i.id, filePath: i.filePath, sources: "storyboard" }))) + } + const assetsIds = items.filter((item: any) => item.sources == "assets").map((item: any) => item.id) + if (assetsIds.length) { + const assetsPaths = await u.db("o_assets").leftJoin("o_image", "o_image.id", "o_assets.imageId").whereIn("o_assets.id", assetsIds).select("o_assets.id", "o_image.filePath"); + totalFilePaths.push(...assetsPaths.map(i => ({ id: i.id, filePath: i.filePath, sources: "assets" }))) + } + console.log("%c Line:30 🍇 totalFilePaths", "background:#93c0a4", totalFilePaths); + + await Promise.all( - paths.map(async (path: string) => { - result[path] = await u.oss.getFileUrl(path.replace(/^\/oss/, '')); + totalFilePaths.map(async (item: { id: string, filePath: string, sources: string }) => { + result[`${item.id}:${item.sources}`] = item.filePath ? await u.oss.getFileUrl(item.filePath) : ""; })) res.status(200).send(success({ data: result }));