feat: add get by id
This commit is contained in:
parent
c1fdf26b39
commit
db88621df1
1 changed files with 13 additions and 1 deletions
|
|
@ -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 prisma from "../db";
|
||||||
import { queryOrNot } from "../utils/relation";
|
import { queryOrNot } from "../utils/relation";
|
||||||
|
import { notFoundError } from "../utils/error";
|
||||||
|
|
||||||
@Route("/api/v1/employment-office")
|
@Route("/api/v1/employment-office")
|
||||||
@Tags("Employment Office")
|
@Tags("Employment Office")
|
||||||
|
|
@ -27,4 +28,15 @@ export class EmploymentOfficeController extends Controller {
|
||||||
orderBy: [{ provinceId: "asc" }, { id: "asc" }],
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue