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

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

@ -6,28 +6,38 @@ import { validateFields } from "@/middleware/middleware";
const router = express.Router();
export default router.post(
"/",
validateFields({
projectId: z.number(),
type: z.array(z.string()).optional(),
}),
async (req, res) => {
const { projectId, type, } = req.body;
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")
.where("o_assets.projectId", projectId)
.andWhere("o_assets.type", "<>", "clip")
.modify((qb) => {
if (type && type.length > 0) qb.whereIn("o_assets.type", type);
});
const result = await Promise.all(
data.map(async (parent: any) => ({
...parent,
filePath: parent.filePath && (await u.oss.getFileUrl(parent.filePath!)),
})),
"/",
validateFields({
projectId: z.number(),
type: z.array(z.string()).optional(),
}),
async (req, res) => {
const { projectId, type } = req.body;
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")
.where("o_assets.projectId", projectId)
.andWhere("o_assets.type", "<>", "clip")
.modify((qb) => {
if (type && type.length > 0) qb.whereIn("o_assets.type", type);
});
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");
const historyImagesWithUrl = await Promise.all(
historyImages.map(async (img: any) => ({
id: img.id,
filePath: img.filePath && (await u.oss.getFileUrl(img.filePath)),
})),
);
res.status(200).send(success(result));
},
return {
...parent,
filePath: parent.filePath && (await u.oss.getFileUrl(parent.filePath!)),
historyImages: historyImagesWithUrl,
};
}),
);
res.status(200).send(success(result));
},
);