fix: work & service code
This commit is contained in:
parent
e7e090ecbd
commit
c978d3adec
2 changed files with 10 additions and 10 deletions
|
|
@ -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