修复删除项目失败
This commit is contained in:
parent
9ad354aa3e
commit
66d2e8b709
@ -12,7 +12,6 @@ export default router.post(
|
||||
}),
|
||||
async (req, res) => {
|
||||
const { id } = req.body;
|
||||
console.log("%c Line:15 🍑 id", "background:#465975", 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 u.db("o_assets").where({ id }).delete();
|
||||
|
||||
@ -14,6 +14,7 @@ export default router.post(
|
||||
async (req, res) => {
|
||||
const { scriptId, specifyIds } = req.body;
|
||||
const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).andWhere("state", "生成中").select("*");
|
||||
console.log("%c Line:17 🧀 data", "background:#93c0a4", data.length);
|
||||
res.status(200).send(success(data));
|
||||
},
|
||||
);
|
||||
@ -20,9 +20,6 @@ export default router.post(
|
||||
const assetsData = await u.db("o_assets").where("projectId", id).select("id");
|
||||
const assetsIds = assetsData.map((item: any) => item.id);
|
||||
|
||||
const videoData = await u.db("o_video").whereIn("scriptId", scriptIds).select("id");
|
||||
const videoIds = videoData.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();
|
||||
@ -31,17 +28,9 @@ export default router.post(
|
||||
await u.db("o_script").where("projectId", id).delete();
|
||||
await u.db("o_assets").where("projectId", id).delete();
|
||||
|
||||
const tempAssetsQuery = u.db("o_image").where("projectId", id);
|
||||
if (assetsIds.length > 0) {
|
||||
tempAssetsQuery.orWhereIn("assetsId", assetsIds);
|
||||
await u.db("o_image").where("projectId", id).orWhereIn("assetsId", assetsIds).delete();
|
||||
}
|
||||
if (scriptIds.length > 0) {
|
||||
tempAssetsQuery.orWhereIn("scriptId", scriptIds);
|
||||
}
|
||||
if (videoIds.length > 0) {
|
||||
tempAssetsQuery.orWhereIn("videoId", videoIds);
|
||||
}
|
||||
await tempAssetsQuery.delete();
|
||||
|
||||
await u.db("o_video").whereIn("scriptId", scriptIds).delete();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user