refactor: relation

This commit is contained in:
Methapon Metanipat 2024-09-30 09:41:54 +07:00
parent 5ccd8909d5
commit e3464c4891

View file

@ -128,15 +128,13 @@ export class ProductGroup extends Controller {
@Security("keycloak")
async getProductGroupById(@Path() groupId: string) {
const record = await prisma.productGroup.findFirst({
include: {
registeredBranch: true,
},
where: { id: groupId },
});
if (!record)
throw new HttpError(
HttpStatus.NOT_FOUND,
"Product group cannot be found.",
"productGroupNotFound",
);
if (!record) throw notFoundError("Product Group");
return record;
}