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";
|
} from "../services/permission";
|
||||||
import { isSystem } from "../utils/keycloak";
|
import { isSystem } from "../utils/keycloak";
|
||||||
import { filterStatus } from "../services/prisma";
|
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 { isUsedError, notFoundError, relationError } from "../utils/error";
|
||||||
import { queryOrNot } from "../utils/relation";
|
import { queryOrNot } from "../utils/relation";
|
||||||
|
|
||||||
|
|
@ -434,6 +434,8 @@ export class ProductController extends Controller {
|
||||||
|
|
||||||
if (record.status !== Status.CREATED) throw isUsedError("Product");
|
if (record.status !== Status.CREATED) throw isUsedError("Product");
|
||||||
|
|
||||||
|
await deleteFolder(fileLocation.product.img(productId));
|
||||||
|
|
||||||
return await prisma.product.delete({
|
return await prisma.product.delete({
|
||||||
include: {
|
include: {
|
||||||
createdBy: true,
|
createdBy: true,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,15 @@ import {
|
||||||
} from "../services/permission";
|
} from "../services/permission";
|
||||||
import { filterStatus } from "../services/prisma";
|
import { filterStatus } from "../services/prisma";
|
||||||
import { isUsedError, notFoundError, relationError } from "../utils/error";
|
import { isUsedError, notFoundError, relationError } from "../utils/error";
|
||||||
import { deleteFile, fileLocation, getFile, getPresigned, listFile, setFile } from "../utils/minio";
|
import {
|
||||||
|
deleteFile,
|
||||||
|
deleteFolder,
|
||||||
|
fileLocation,
|
||||||
|
getFile,
|
||||||
|
getPresigned,
|
||||||
|
listFile,
|
||||||
|
setFile,
|
||||||
|
} from "../utils/minio";
|
||||||
import { queryOrNot } from "../utils/relation";
|
import { queryOrNot } from "../utils/relation";
|
||||||
|
|
||||||
const MANAGE_ROLES = [
|
const MANAGE_ROLES = [
|
||||||
|
|
@ -560,6 +568,8 @@ export class ServiceController extends Controller {
|
||||||
|
|
||||||
if (record.status !== Status.CREATED) throw isUsedError("Service");
|
if (record.status !== Status.CREATED) throw isUsedError("Service");
|
||||||
|
|
||||||
|
await deleteFolder(fileLocation.service.img(serviceId));
|
||||||
|
|
||||||
return await prisma.service.delete({
|
return await prisma.service.delete({
|
||||||
include: {
|
include: {
|
||||||
createdBy: true,
|
createdBy: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue