no message
This commit is contained in:
parent
1d0f80a035
commit
5e826586db
@ -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<string, string> = {};
|
||||
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 }));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user