feat: return only one record
This commit is contained in:
parent
fc8e81b780
commit
0bca85d460
1 changed files with 1 additions and 12 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue