diff --git a/src/controllers/00-employment-office-controller.ts b/src/controllers/00-employment-office-controller.ts index 6e54199..700cad9 100644 --- a/src/controllers/00-employment-office-controller.ts +++ b/src/controllers/00-employment-office-controller.ts @@ -1,11 +1,12 @@ import { Controller, Get, Query, Route, Tags } from "tsoa"; import prisma from "../db"; +import { queryOrNot } from "../utils/relation"; @Route("/api/v1/employment-office") @Tags("Employment Office") export class EmploymentOfficeController extends Controller { @Get() - async getEmploymentOfficeList(@Query() districtId?: string) { + async getEmploymentOfficeList(@Query() districtId?: string, @Query() query: string = "") { return await prisma.employmentOffice.findMany({ where: { OR: [ @@ -20,6 +21,7 @@ export class EmploymentOfficeController extends Controller { some: { districtId }, }, }, + ...(queryOrNot(query, [{ name: query }, { nameEN: query }]) ?? []), ], }, orderBy: [{ provinceId: "asc" }, { id: "asc" }],