修复删除项目,删除资产数据删除不全问题
This commit is contained in:
parent
b55e896def
commit
59bb3e130b
@ -14,6 +14,7 @@ export default router.post(
|
|||||||
const { id } = req.body;
|
const { id } = req.body;
|
||||||
const assetsData = await u.db("o_image").where("assetsId", id);
|
const assetsData = await u.db("o_image").where("assetsId", id);
|
||||||
await Promise.all(assetsData.map((i) => i.filePath && u.oss.deleteFile(i.filePath)));
|
await Promise.all(assetsData.map((i) => i.filePath && u.oss.deleteFile(i.filePath)));
|
||||||
|
await u.db("o_image").where({ assetsId: id }).delete();
|
||||||
await u.db("o_assets").where({ id }).delete();
|
await u.db("o_assets").where({ id }).delete();
|
||||||
res.status(200).send(success({ message: "删除资产成功" }));
|
res.status(200).send(success({ message: "删除资产成功" }));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -13,6 +13,9 @@ export default router.post(
|
|||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { id } = req.body;
|
const { id } = req.body;
|
||||||
await u.db("o_video").where("id", id).delete();
|
await u.db("o_video").where("id", id).delete();
|
||||||
|
await u.db("o_videoTrack").where("videoId", id).update({
|
||||||
|
videoId: null,
|
||||||
|
});
|
||||||
res.status(200).send(success({ message: "视频删除成功" }));
|
res.status(200).send(success({ message: "视频删除成功" }));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -13,27 +13,35 @@ export default router.post(
|
|||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { id } = req.body;
|
const { id } = req.body;
|
||||||
|
//删除项目
|
||||||
const scriptData = await u.db("o_script").where("projectId", id).select("id");
|
await u.db("o_project").where("id", id).delete();
|
||||||
const scriptIds = scriptData.map((item: any) => item.id);
|
//删除项目下的原文
|
||||||
|
await u.db("o_novel").where("projectId", id).delete();
|
||||||
|
// 删除项目下的剧本信息
|
||||||
|
await u.db("o_script").where("projectId", id).delete();
|
||||||
|
await u.db("o_outline").where("projectId", id).delete();
|
||||||
|
// 删除项目下的任务
|
||||||
|
await u.db("o_tasks").where("projectId", id).delete();
|
||||||
|
// 删除项目下的分镜
|
||||||
|
await u.db("o_storyboard").where("projectId", id).delete();
|
||||||
|
// 删除项目下的资产
|
||||||
|
await u.db("o_assets").where("projectId", id).delete();
|
||||||
|
//删除需要删除资产的归属图片
|
||||||
const assetsData = await u.db("o_assets").where("projectId", id).select("id");
|
const assetsData = await u.db("o_assets").where("projectId", id).select("id");
|
||||||
const assetsIds = assetsData.map((item: any) => item.id);
|
const assetsIds = assetsData.map((item: any) => item.id);
|
||||||
|
|
||||||
await u.db("o_project").where("id", id).delete();
|
|
||||||
await u.db("o_novel").where("projectId", id).delete();
|
|
||||||
await u.db("o_outline").where("projectId", id).delete();
|
|
||||||
await u.db("o_tasks").where("projectId", id).delete();
|
|
||||||
|
|
||||||
await u.db("o_script").where("projectId", id).delete();
|
|
||||||
await u.db("o_assets").where("projectId", id).delete();
|
|
||||||
|
|
||||||
if (assetsIds.length > 0) {
|
if (assetsIds.length > 0) {
|
||||||
await u.db("o_image").where("projectId", id).orWhereIn("assetsId", assetsIds).delete();
|
await u.db("o_image").orWhereIn("assetsId", assetsIds).delete();
|
||||||
}
|
}
|
||||||
|
//删除项目下的视频
|
||||||
await u.db("o_video").whereIn("scriptId", scriptIds).delete();
|
const videoData = await u.db("o_video").where("projectId", id).select("id");
|
||||||
|
const videoIds = videoData.map((item: any) => item.id);
|
||||||
|
if (videoIds.length > 0) {
|
||||||
|
await u.db("o_videoTrack").whereIn("videoId", videoIds).update({
|
||||||
|
videoId: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await u.db("o_video").where("projectId", id).delete();
|
||||||
|
//删除项目下的资源
|
||||||
try {
|
try {
|
||||||
await u.oss.deleteDirectory(`${id}/`);
|
await u.oss.deleteDirectory(`${id}/`);
|
||||||
console.log(`项目 ${id} 的OSS文件夹删除成功`);
|
console.log(`项目 ${id} 的OSS文件夹删除成功`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user