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,