feat: update field
This commit is contained in:
parent
c079f43e8d
commit
af4489dccc
7 changed files with 162 additions and 160 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { Prisma, Status } from "@prisma/client";
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
|
|
@ -7,7 +6,6 @@ import {
|
|||
Put,
|
||||
Path,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -19,32 +17,19 @@ import HttpError from "../interfaces/http-error";
|
|||
import HttpStatus from "../interfaces/http-status";
|
||||
import { RequestWithUser } from "../interfaces/user";
|
||||
|
||||
type EmployeeOtherInfoCreate = {
|
||||
citizenId: string;
|
||||
fatherFirstName: string;
|
||||
fatherLastName: string;
|
||||
motherFirstName: string;
|
||||
motherLastName: string;
|
||||
type EmployeeOtherInfoPayload = {
|
||||
citizenId?: string | null;
|
||||
fatherFirstName?: string | null;
|
||||
fatherLastName?: string | null;
|
||||
fatherBirthPlace?: string | null;
|
||||
motherFirstName?: string | null;
|
||||
motherLastName?: string | null;
|
||||
motherBirthPlace?: string | null;
|
||||
|
||||
fatherFirstNameEN: string;
|
||||
fatherLastNameEN: string;
|
||||
motherFirstNameEN: string;
|
||||
motherLastNameEN: string;
|
||||
birthPlace: string;
|
||||
};
|
||||
|
||||
type EmployeeOtherInfoUpdate = {
|
||||
citizenId: string;
|
||||
fatherFirstName: string;
|
||||
fatherLastName: string;
|
||||
motherFirstName: string;
|
||||
motherLastName: string;
|
||||
|
||||
fatherFirstNameEN: string;
|
||||
fatherLastNameEN: string;
|
||||
motherFirstNameEN: string;
|
||||
motherLastNameEN: string;
|
||||
birthPlace: string;
|
||||
fatherFirstNameEN?: string | null;
|
||||
fatherLastNameEN?: string | null;
|
||||
motherFirstNameEN?: string | null;
|
||||
motherLastNameEN?: string | null;
|
||||
};
|
||||
|
||||
@Route("api/v1/employee/{employeeId}/other-info")
|
||||
|
|
@ -74,7 +59,7 @@ export class EmployeeOtherInfo extends Controller {
|
|||
async create(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() employeeId: string,
|
||||
@Body() body: EmployeeOtherInfoCreate,
|
||||
@Body() body: EmployeeOtherInfoPayload,
|
||||
) {
|
||||
if (!(await prisma.employee.findUnique({ where: { id: employeeId } })))
|
||||
throw new HttpError(
|
||||
|
|
@ -102,7 +87,7 @@ export class EmployeeOtherInfo extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Path() employeeId: string,
|
||||
@Path() otherInfoId: string,
|
||||
@Body() body: EmployeeOtherInfoUpdate,
|
||||
@Body() body: EmployeeOtherInfoPayload,
|
||||
) {
|
||||
if (!(await prisma.employeeOtherInfo.findUnique({ where: { id: otherInfoId, employeeId } }))) {
|
||||
throw new HttpError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue