添加查询资产返回历史资产图片

This commit is contained in:
小帅 2026-03-29 23:11:41 +08:00
parent 618007d80b
commit bb09702551
14 changed files with 33 additions and 36 deletions

View File

@ -1 +0,0 @@
1212水电费水电费萨芬的水电费

View File

@ -1 +0,0 @@
1212

View File

@ -31,7 +31,6 @@ export default router.post(
imageId: assets!.imageId ?? null,
tempAssets,
};
console.log("%c Line:30 🥤 data", "background:#465975", data);
res.status(200).send(success(data));
},
);

View File

@ -12,7 +12,7 @@ export default router.post(
type: z.array(z.string()).optional(),
}),
async (req, res) => {
const { projectId, type, } = req.body;
const { projectId, type } = req.body;
const data = await u
.db("o_assets")
.leftJoin("o_image", "o_assets.imageId", "o_image.id")
@ -23,10 +23,20 @@ export default router.post(
if (type && type.length > 0) qb.whereIn("o_assets.type", type);
});
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 historyImagesWithUrl = await Promise.all(
historyImages.map(async (img: any) => ({
id: img.id,
filePath: img.filePath && (await u.oss.getFileUrl(img.filePath)),
})),
);
return {
...parent,
filePath: parent.filePath && (await u.oss.getFileUrl(parent.filePath!)),
})),
historyImages: historyImagesWithUrl,
};
}),
);
res.status(200).send(success(result));
},