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 { Controller, Get, Query, Route, Tags } from "tsoa";
|
||||||
import prisma from "../db";
|
import prisma from "../db";
|
||||||
|
import { queryOrNot } from "../utils/relation";
|
||||||
|
|
||||||
@Route("/api/v1/employment-office")
|
@Route("/api/v1/employment-office")
|
||||||
@Tags("Employment Office")
|
@Tags("Employment Office")
|
||||||
export class EmploymentOfficeController extends Controller {
|
export class EmploymentOfficeController extends Controller {
|
||||||
@Get()
|
@Get()
|
||||||
async getEmploymentOfficeList(@Query() districtId?: string) {
|
async getEmploymentOfficeList(@Query() districtId?: string, @Query() query: string = "") {
|
||||||
return await prisma.employmentOffice.findMany({
|
return await prisma.employmentOffice.findMany({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
OR: [
|
||||||
|
|
@ -20,6 +21,7 @@ export class EmploymentOfficeController extends Controller {
|
||||||
some: { districtId },
|
some: { districtId },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
...(queryOrNot(query, [{ name: query }, { nameEN: query }]) ?? []),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
orderBy: [{ provinceId: "asc" }, { id: "asc" }],
|
orderBy: [{ provinceId: "asc" }, { id: "asc" }],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue