From 3f43ad1b9bbf7e3fd865b1761c0f4f19736100cc Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:09:44 +0700 Subject: [PATCH] feat: get customer branch by id --- src/controllers/customer-branch-controller.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/controllers/customer-branch-controller.ts b/src/controllers/customer-branch-controller.ts index 8ece315..5b6b7b6 100644 --- a/src/controllers/customer-branch-controller.ts +++ b/src/controllers/customer-branch-controller.ts @@ -121,6 +121,24 @@ export class CustomerBranchController extends Controller { return { result, page, pageSize, total }; } + @Get("{branchId}") + async getById(@Path() branchId: string) { + const record = await prisma.customerBranch.findFirst({ + include: { + province: true, + district: true, + subDistrict: true, + }, + where: { id: branchId }, + }); + + if (!record) { + throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found"); + } + + return record; + } + @Get("{branchId}/employee") async listEmployee( @Path() branchId: string,