From f2d0c20ece942c271c62cd8b14ea2861c02b5315 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 17 Apr 2025 12:56:31 +0700 Subject: [PATCH] feat: add endpoint for get same office district --- .../00-employment-office-controller.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/controllers/00-employment-office-controller.ts b/src/controllers/00-employment-office-controller.ts index 95adc5a..9c6995b 100644 --- a/src/controllers/00-employment-office-controller.ts +++ b/src/controllers/00-employment-office-controller.ts @@ -12,6 +12,39 @@ export class EmploymentOfficeController extends Controller { return this.getEmploymentOfficeListByCriteria(districtId, query); } + @Post("list-same-office-area") + async getSameOfficeArea(@Body() body: { districtId: string }) { + const office = await prisma.employmentOffice.findFirst({ + include: { + province: { + include: { + district: true, + }, + }, + district: true, + }, + where: { + OR: [ + { + province: { district: { some: { id: body.districtId } } }, + district: { none: {} }, + }, + { + district: { + some: { districtId: body.districtId }, + }, + }, + ], + }, + }); + if (!office) return []; + + return [ + ...office.district.map((v) => v.districtId), + ...office.province.district.map((v) => v.id), + ]; + } + @Post("list") async getEmploymentOfficeListByCriteria( @Query() districtId?: string,