feat: add get by id

This commit is contained in:
Methapon Metanipat 2024-11-14 17:09:42 +07:00
parent c1fdf26b39
commit db88621df1

View file

@ -1,6 +1,7 @@
import { Controller, Get, Query, Route, Tags } from "tsoa";
import { Controller, Get, Path, Query, Route, Tags } from "tsoa";
import prisma from "../db";
import { queryOrNot } from "../utils/relation";
import { notFoundError } from "../utils/error";
@Route("/api/v1/employment-office")
@Tags("Employment Office")
@ -27,4 +28,15 @@ export class EmploymentOfficeController extends Controller {
orderBy: [{ provinceId: "asc" }, { id: "asc" }],
});
}
@Get("{employmentOfficeId}")
async getEmploymentOffice(@Path() employmentOfficeId: string) {
const record = await prisma.employmentOffice.findFirst({
where: { id: employmentOfficeId },
});
if (!record) throw notFoundError("Employment Office");
return record;
}
}