fix: product code
This commit is contained in:
parent
5dbc261a79
commit
fa8e21166b
1 changed files with 4 additions and 4 deletions
|
|
@ -97,7 +97,7 @@ export class ProductController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "data_not_found");
|
throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "productNotFound");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.assign(record, {
|
return Object.assign(record, {
|
||||||
|
|
@ -156,7 +156,7 @@ export class ProductController extends Controller {
|
||||||
@Path() productId: string,
|
@Path() productId: string,
|
||||||
) {
|
) {
|
||||||
if (!(await prisma.product.findUnique({ where: { id: productId } }))) {
|
if (!(await prisma.product.findUnique({ where: { id: productId } }))) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "data_not_found");
|
throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "productNotFound");
|
||||||
}
|
}
|
||||||
|
|
||||||
const record = await prisma.product.update({
|
const record = await prisma.product.update({
|
||||||
|
|
@ -182,11 +182,11 @@ export class ProductController extends Controller {
|
||||||
const record = await prisma.product.findFirst({ where: { id: productId } });
|
const record = await prisma.product.findFirst({ where: { id: productId } });
|
||||||
|
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "data_not_found");
|
throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "productNotFound");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.status !== Status.CREATED) {
|
if (record.status !== Status.CREATED) {
|
||||||
throw new HttpError(HttpStatus.FORBIDDEN, "Product is in used.", "data_in_used");
|
throw new HttpError(HttpStatus.FORBIDDEN, "Product is in used.", "productInUsed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await prisma.product.delete({ where: { id: productId } });
|
return await prisma.product.delete({ where: { id: productId } });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue