fix: work & service code
This commit is contained in:
parent
e7e090ecbd
commit
c978d3adec
2 changed files with 10 additions and 10 deletions
|
|
@ -124,7 +124,7 @@ export class ServiceController extends Controller {
|
|||
});
|
||||
|
||||
if (!record)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Service cannot be found.", "data_not_found");
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Service cannot be found.", "serviceNotFound");
|
||||
|
||||
return Object.assign(record, {
|
||||
imageUrl: await presignedGetObjectIfExist(MINIO_BUCKET, imageLocation(record.id), 60 * 60),
|
||||
|
|
@ -173,7 +173,7 @@ export class ServiceController extends Controller {
|
|||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"Some product not found.",
|
||||
"missing_or_invalid_parameter",
|
||||
"someProductBadReq",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ export class ServiceController extends Controller {
|
|||
@Path() serviceId: string,
|
||||
) {
|
||||
if (!(await prisma.service.findUnique({ where: { id: serviceId } }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Service cannot be found.", "data_not_found");
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Service cannot be found.", "serviceNotFound");
|
||||
}
|
||||
|
||||
const record = await prisma.service.update({
|
||||
|
|
@ -276,11 +276,11 @@ export class ServiceController extends Controller {
|
|||
const record = await prisma.service.findFirst({ where: { id: serviceId } });
|
||||
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Service cannot be found.", "data_not_found");
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Service cannot be found.", "serviceNotFound");
|
||||
}
|
||||
|
||||
if (record.status !== Status.CREATED) {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "Service is in used.", "data_in_used");
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "Service is in used.", "serviceInUsed");
|
||||
}
|
||||
|
||||
return await prisma.service.delete({ where: { id: serviceId } });
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ export class WorkController extends Controller {
|
|||
});
|
||||
|
||||
if (!record)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "data_not_found");
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "workNotFound");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ export class WorkController extends Controller {
|
|||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"Some product not found.",
|
||||
"missing_or_invalid_parameter",
|
||||
"someProductBadReq",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ export class WorkController extends Controller {
|
|||
const { productId, ...payload } = body;
|
||||
|
||||
if (!(await prisma.work.findUnique({ where: { id: workId } }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "data_not_found");
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "workNotFound");
|
||||
}
|
||||
|
||||
const exist = await prisma.work.findFirst({
|
||||
|
|
@ -301,11 +301,11 @@ export class WorkController extends Controller {
|
|||
const record = await prisma.work.findFirst({ where: { id: workId } });
|
||||
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "data_not_found");
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "workNotFound");
|
||||
}
|
||||
|
||||
if (record.status !== Status.CREATED) {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "Work is in used.", "missing_or_invalid_parameter");
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "Work is in used.", "workInUsed");
|
||||
}
|
||||
|
||||
return await prisma.work.delete({ where: { id: workId } });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue