feat: handle file remove on delete resource
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 10s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 10s
This commit is contained in:
parent
9c7921fa7c
commit
f98028fe6e
2 changed files with 14 additions and 2 deletions
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from "../services/permission";
|
||||
import { isSystem } from "../utils/keycloak";
|
||||
import { filterStatus } from "../services/prisma";
|
||||
import { deleteFile, fileLocation, getFile, listFile, setFile } from "../utils/minio";
|
||||
import { deleteFile, deleteFolder, fileLocation, getFile, listFile, setFile } from "../utils/minio";
|
||||
import { isUsedError, notFoundError, relationError } from "../utils/error";
|
||||
import { queryOrNot } from "../utils/relation";
|
||||
|
||||
|
|
@ -434,6 +434,8 @@ export class ProductController extends Controller {
|
|||
|
||||
if (record.status !== Status.CREATED) throw isUsedError("Product");
|
||||
|
||||
await deleteFolder(fileLocation.product.img(productId));
|
||||
|
||||
return await prisma.product.delete({
|
||||
include: {
|
||||
createdBy: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue