From 239582b4722ea6b9a2c48f1915c1f59d60ec5564 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:00:44 +0700 Subject: [PATCH] feat: list customer by id --- src/controllers/customer-controller.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/controllers/customer-controller.ts b/src/controllers/customer-controller.ts index a02da59..74748bf 100644 --- a/src/controllers/customer-controller.ts +++ b/src/controllers/customer-controller.ts @@ -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({