feat: update work endpoints
This commit is contained in:
parent
39206a6d76
commit
51fd6b0589
4 changed files with 76 additions and 72 deletions
|
|
@ -20,6 +20,7 @@ import HttpError from "../../interfaces/http-error";
|
|||
import HttpStatus from "../../interfaces/http-status";
|
||||
|
||||
type WorkCreate = {
|
||||
order: number;
|
||||
name: string;
|
||||
productId: string[];
|
||||
attributes?: {
|
||||
|
|
@ -28,6 +29,7 @@ type WorkCreate = {
|
|||
};
|
||||
|
||||
type WorkUpdate = {
|
||||
order?: number;
|
||||
name?: string;
|
||||
productId?: string[];
|
||||
attributes?: {
|
||||
|
|
@ -78,8 +80,7 @@ export class WorkController extends Controller {
|
|||
where: { id: workId },
|
||||
});
|
||||
|
||||
if (!record)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "workNotFound");
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "Work cannot be found.", "workNotFound");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
|
@ -160,11 +161,7 @@ export class WorkController extends Controller {
|
|||
});
|
||||
|
||||
if (productList.length !== productId.length) {
|
||||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"Some product not found.",
|
||||
"someProductBadReq",
|
||||
);
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "Some product not found.", "someProductBadReq");
|
||||
}
|
||||
|
||||
const record = await prisma.work.create({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue