添加查询资产返回历史资产图片
This commit is contained in:
parent
618007d80b
commit
bb09702551
@ -1 +0,0 @@
|
|||||||
1212水电费水电费萨芬的水电费
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1212
|
|
||||||
@ -31,7 +31,6 @@ export default router.post(
|
|||||||
imageId: assets!.imageId ?? null,
|
imageId: assets!.imageId ?? null,
|
||||||
tempAssets,
|
tempAssets,
|
||||||
};
|
};
|
||||||
console.log("%c Line:30 🥤 data", "background:#465975", data);
|
|
||||||
res.status(200).send(success(data));
|
res.status(200).send(success(data));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,28 +6,38 @@ import { validateFields } from "@/middleware/middleware";
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
export default router.post(
|
export default router.post(
|
||||||
"/",
|
"/",
|
||||||
validateFields({
|
validateFields({
|
||||||
projectId: z.number(),
|
projectId: z.number(),
|
||||||
type: z.array(z.string()).optional(),
|
type: z.array(z.string()).optional(),
|
||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { projectId, type, } = req.body;
|
const { projectId, type } = req.body;
|
||||||
const data = await u
|
const data = await u
|
||||||
.db("o_assets")
|
.db("o_assets")
|
||||||
.leftJoin("o_image", "o_assets.imageId", "o_image.id")
|
.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")
|
||||||
.where("o_assets.projectId", projectId)
|
.where("o_assets.projectId", projectId)
|
||||||
.andWhere("o_assets.type", "<>", "clip")
|
.andWhere("o_assets.type", "<>", "clip")
|
||||||
.modify((qb) => {
|
.modify((qb) => {
|
||||||
if (type && type.length > 0) qb.whereIn("o_assets.type", type);
|
if (type && type.length > 0) qb.whereIn("o_assets.type", type);
|
||||||
});
|
});
|
||||||
const result = await Promise.all(
|
const result = await Promise.all(
|
||||||
data.map(async (parent: any) => ({
|
data.map(async (parent: any) => {
|
||||||
...parent,
|
const historyImages = await u.db("o_image").where("assetsId", parent.id).andWhere("state", "已完成").select("id", "filePath");
|
||||||
filePath: parent.filePath && (await u.oss.getFileUrl(parent.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));
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user