fix: group code

This commit is contained in:
puriphat 2024-06-14 04:40:10 +00:00
parent 9722fab149
commit 5dbc261a79

View file

@ -56,7 +56,7 @@ export class ProductGroup extends Controller {
});
if (!record)
throw new HttpError(HttpStatus.NOT_FOUND, "Product group cannot be found.", "data_not_found");
throw new HttpError(HttpStatus.NOT_FOUND, "Product group cannot be found.", "productGroupNotFound");
return record;
}
@ -100,7 +100,7 @@ export class ProductGroup extends Controller {
@Path() groupId: string,
) {
if (!(await prisma.productGroup.findUnique({ where: { id: groupId } }))) {
throw new HttpError(HttpStatus.NOT_FOUND, "Product group cannot be found.", "data_not_found");
throw new HttpError(HttpStatus.NOT_FOUND, "Product group cannot be found.", "productGroupNotFound");
}
const record = await prisma.productGroup.update({
@ -116,11 +116,11 @@ export class ProductGroup extends Controller {
const record = await prisma.productGroup.findFirst({ where: { id: groupId } });
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "Product group cannot be found.", "data_not_found");
throw new HttpError(HttpStatus.NOT_FOUND, "Product group cannot be found.", "productGroupNotFound");
}
if (record.status !== Status.CREATED) {
throw new HttpError(HttpStatus.FORBIDDEN, "Product group is in used.", "data_in_used");
throw new HttpError(HttpStatus.FORBIDDEN, "Product group is in used.", "productGroupInUsed");
}
return await prisma.productGroup.delete({ where: { id: groupId } });