30 lines
900 B
TypeScript
30 lines
900 B
TypeScript
import express from "express";
|
|
import u from "@/utils";
|
|
import { z } from "zod";
|
|
import { success } from "@/lib/responseFormat";
|
|
import { validateFields } from "@/middleware/middleware";
|
|
const router = express.Router();
|
|
|
|
export default router.post(
|
|
"/",
|
|
validateFields({
|
|
ids: z.array(z.number()),
|
|
}),
|
|
async (req, res) => {
|
|
const { ids } = req.body;
|
|
const data = await u
|
|
.db("o_assets")
|
|
.leftJoin("o_image", "o_assets.imageId", "o_image.id")
|
|
.whereIn("o_assets.id", ids)
|
|
.whereNot("o_image.state", "生成中")
|
|
.select("o_image.state", "o_assets.id", "o_image.filePath", "o_image.errorReason","o_assets.prompt");
|
|
const result = await Promise.all(
|
|
data.map(async (item: any) => ({
|
|
...item,
|
|
src: item.filePath ? await u.oss.getFileUrl(item.filePath) : null,
|
|
})),
|
|
);
|
|
res.status(200).send(success(result));
|
|
},
|
|
);
|