video-flow-toon/src/routes/assets/delAssetsImage.ts
2026-02-26 18:43:05 +08:00

28 lines
732 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({
imageId: z.number().optional(),
assetsId: z.number().optional(),
}),
async (req, res) => {
const { imageId, assetsId } = req.body;
if (assetsId) {
await u.db("t_assets").where("id", assetsId).update({
filePath: null,
});
}
if (imageId) {
await u.db("t_image").where("id", imageId).delete();
}
res.status(200).send(success({ message: "删除资产图片成功" }));
},
);