feat: add normal search for employment office
This commit is contained in:
parent
401d376a63
commit
c1fdf26b39
1 changed files with 3 additions and 1 deletions
|
|
@ -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" }],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue