feat: employment office (#5)

* feat: add table employment office

* feat: add tag

* feat: add employment office

* chore: migrations

* feat: order employment office

* feat: delete old employment office when special got added
This commit is contained in:
Methapon Metanipat 2024-11-14 15:10:58 +07:00 committed by GitHub
parent 22b3981aa7
commit 401d376a63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 171 additions and 1 deletions

View file

@ -0,0 +1,28 @@
import { Controller, Get, Query, Route, Tags } from "tsoa";
import prisma from "../db";
@Route("/api/v1/employment-office")
@Tags("Employment Office")
export class EmploymentOfficeController extends Controller {
@Get()
async getEmploymentOfficeList(@Query() districtId?: string) {
return await prisma.employmentOffice.findMany({
where: {
OR: [
{
province: {
district: { some: { id: districtId } },
},
district: { none: {} },
},
{
district: {
some: { districtId },
},
},
],
},
orderBy: [{ provinceId: "asc" }, { id: "asc" }],
});
}
}