ACT丶流星雨 0798ae03ee no message
2026-01-29 18:28:32 +08:00

31 lines
744 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({
projectId: z.number(),
type: z.string(),
}),
async (req, res) => {
const { projectId, type } = req.body;
const data = await u.db("t_assets").where("projectId", projectId).where("type", type).select("*");
for (const item of data) {
if (item.filePath) {
item.filePath = await u.oss.getFileUrl(item.filePath);
} else {
item.filePath = "";
}
}
res.status(200).send(success(data));
}
);