From e5f71ba90dff1cf8a9de4ee40bacad6c8695004b Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 7 May 2024 14:49:39 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9E=E0=B8=9A=E0=B9=80=E0=B8=A5=E0=B8=82?= =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=95=E0=B8=A3=E0=B9=83=E0=B8=AB=E0=B9=89?= =?UTF-8?q?=20return=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 8 ++--- src/entities/Profile.ts | 52 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 45555676..cd3c7dfb 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -216,11 +216,9 @@ export class ProfileController extends Controller { @Request() request: RequestWithUser, @Body() body: CreateProfileAllFields, ) { - if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) { - throw new HttpError( - HttpStatus.INTERNAL_SERVER_ERROR, - "เลขประจำตัวประชาชนนี้มีอยู่ในระบบแล้ว", - ); + const profileExist = await this.profileRepo.findOneBy({ citizenId: body.citizenId }) + if (profileExist) { + return new HttpSuccess(profileExist.id); } if (body.posLevelId === "") body.posLevelId = null; diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index f9c03233..8befca12 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -564,43 +564,43 @@ export class CreateProfile { } export class CreateProfileAllFields { - rank: string; + rank: string | null; prefix: string; firstName: string; lastName: string; citizenId: string; - position: string; + position: string | null; posLevelId: string | null; posTypeId: string | null; - email: string; - phone: string; - keycloak: string; - isProbation: boolean; - isLeave : boolean; + email: string | null; + phone: string | null; + keycloak: string | null; + isProbation: boolean | null; + isLeave : boolean | null; dateRetire : Date | null; dateAppoint : Date | null; dateStart: Date | null; - govAgeAbsent: number; - govAgePlus: number; + govAgeAbsent: number | null; + govAgePlus: number | null; birthDate: Date | null; reasonSameDate : Date | null; - ethnicity : string; - telephoneNumber : string; - nationality : string; - gender : string; - relationship : string; - religion : string; - bloodGroup : string; - registrationAddress : string; - registrationProvinceId : string; - registrationDistrictId: string; - registrationSubDistrictId : string; - registrationZipCode : string; - currentAddress : string; - currentProvinceId : string; - currentDistrictId : string; - currentSubDistrictId : string; - currentZipCode : string; + ethnicity : string | null; + telephoneNumber : string | null; + nationality : string | null; + gender : string | null; + relationship : string | null; + religion : string | null; + bloodGroup : string | null; + registrationAddress : string | null; + registrationProvinceId : string | null; + registrationDistrictId: string | null; + registrationSubDistrictId : string | null; + registrationZipCode : string | null; + currentAddress : string | null; + currentProvinceId : string | null; + currentDistrictId : string | null; + currentSubDistrictId : string | null; + currentZipCode : string | null; }; export type UpdateProfile = {