feat: return only one record

This commit is contained in:
Methapon2001 2024-06-12 14:41:07 +07:00
parent fc8e81b780
commit 0bca85d460

View file

@ -38,23 +38,12 @@ type EmployeeOtherInfoPayload = {
export class EmployeeOtherInfo extends Controller {
@Get()
async list(@Path() employeeId: string) {
return prisma.employeeOtherInfo.findMany({
return prisma.employeeOtherInfo.findFirst({
orderBy: { createdAt: "asc" },
where: { employeeId },
});
}
@Get("{otherInfoId}")
async getById(@Path() employeeId: string, @Path() otherInfoId: string) {
const record = await prisma.employeeOtherInfo.findFirst({
where: { id: otherInfoId, employeeId },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "Employee info cannot be found.", "data_not_found");
}
return record;
}
@Post()
async create(
@Request() req: RequestWithUser,