feat: list customer by id

This commit is contained in:
Methapon2001 2024-04-05 11:00:44 +07:00
parent e76650bfce
commit 239582b472

View file

@ -82,6 +82,14 @@ export class CustomerController extends Controller {
};
}
@Get("{customerId}")
async getById(@Path() customerId: string) {
const record = await prisma.customer.findFirst({ where: { id: customerId } });
if (!record)
throw new HttpError(HttpStatus.NOT_FOUND, "Customer cannot be found.", "data_not_found");
return record;
}
@Post()
async create(@Request() req: RequestWithUser, @Body() body: CustomerCreate) {
const record = await prisma.customer.create({