diff --git a/src/controllers/00-employment-office-controller.ts b/src/controllers/00-employment-office-controller.ts index ed7a0c8..34db251 100644 --- a/src/controllers/00-employment-office-controller.ts +++ b/src/controllers/00-employment-office-controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Path, Query, Route, Tags } from "tsoa"; +import { Body, Controller, Get, Path, Post, Query, Route, Tags } from "tsoa"; import prisma from "../db"; import { queryOrNot } from "../utils/relation"; import { notFoundError } from "../utils/error"; @@ -8,10 +8,22 @@ import { notFoundError } from "../utils/error"; export class EmploymentOfficeController extends Controller { @Get() async getEmploymentOfficeList(@Query() districtId?: string, @Query() query: string = "") { + this.getEmploymentOfficeListByCriteria(districtId, query); + } + + @Post("list") + async getEmploymentOfficeListByCriteria( + @Query() districtId?: string, + @Query() query: string = "", + @Body() + body?: { + id?: string[]; + }, + ) { return await prisma.employmentOffice.findMany({ where: { OR: - districtId || query + districtId || query || body?.id ? [ ...queryOrNot( !!districtId, @@ -33,6 +45,7 @@ export class EmploymentOfficeController extends Controller { [{ name: { contains: query } }, { nameEN: { contains: query } }], [], ), + ...queryOrNot(!!body?.id, [{ id: { in: body?.id } }], []), ] : undefined, },