From d96a6319b6e61ffe9148dd1e37c132209d994c3a Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Wed, 29 May 2024 15:51:58 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=20profile=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B9=80=E0=B8=95=E0=B8=B4=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 144 +++++++++++++-------------- 1 file changed, 71 insertions(+), 73 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 8dbcbdd7..38131ed8 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -301,73 +301,71 @@ export class ProfileController extends Controller { const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; - const Profile = [ - { - CitizenId: - profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "", - Prefix: profiles?.prefix != null ? profiles.prefix : "", - FirstName: profiles?.firstName != null ? profiles.firstName : "", - LastName: profiles?.lastName != null ? profiles.lastName : "", - FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, - BirthDay: profiles?.birthDate - ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString()) + const Profile = { + CitizenId: + profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "", + Prefix: profiles?.prefix != null ? profiles.prefix : "", + FirstName: profiles?.firstName != null ? profiles.firstName : "", + LastName: profiles?.lastName != null ? profiles.lastName : "", + FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, + BirthDay: profiles?.birthDate + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString()) + : null, + BirthDayText: + profiles.birthDate != null + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) + : "", + BirthMonth: profiles?.birthDate + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString()) + : null, // Months are zero-based + BirthYear: profiles?.birthDate + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString()) + : null, + BirthYearText: + profiles.birthDate != null + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) + : "", + Address: "", + District: "", + Area: "", + Province: "", + Telephone: profiles?.telephoneNumber ?? null, + CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, + CouplePrefix: profileFamilyCouple?.couplePrefix ?? "", + CoupleFullName: + profileFamilyCouple?.couplePrefix || + profileFamilyCouple?.coupleFirstName || + profileFamilyCouple?.coupleLastNameOld + ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() : null, - BirthDayText: - profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) - : "", - BirthMonth: profiles?.birthDate - ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString()) - : null, // Months are zero-based - BirthYear: profiles?.birthDate - ? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString()) + FatherPrefix: profileFamilyFather?.fatherPrefix ?? "", + FatherFullName: + profileFamilyFather?.fatherPrefix || + profileFamilyFather?.fatherFirstName || + profileFamilyFather?.fatherLastName + ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() : null, - BirthYearText: - profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) - : "", - Address: "", - District: "", - Area: "", - Province: "", - Telephone: profiles?.telephoneNumber ?? null, - CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, - CouplePrefix: profileFamilyCouple?.couplePrefix ?? "", - CoupleFullName: - profileFamilyCouple?.couplePrefix || - profileFamilyCouple?.coupleFirstName || - profileFamilyCouple?.coupleLastNameOld - ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() - : null, - FatherPrefix: profileFamilyFather?.fatherPrefix ?? "", - FatherFullName: - profileFamilyFather?.fatherPrefix || - profileFamilyFather?.fatherFirstName || - profileFamilyFather?.fatherLastName - ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() - : null, - MotherPrefix: profileFamilyMother?.motherPrefix ?? "", - MotherFullName: - profileFamilyMother?.motherPrefix || - profileFamilyMother?.motherFirstName || - profileFamilyMother?.motherLastName - ? `${profileFamilyMother?.motherPrefix ?? ""} ${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() - : null, - OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, - Division: "", - Institute: "", - StartDate: profiles?.dateStart, - AppointDate: profiles?.dateAppoint, - BirthDate: profiles?.birthDate - ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) + MotherPrefix: profileFamilyMother?.motherPrefix ?? "", + MotherFullName: + profileFamilyMother?.motherPrefix || + profileFamilyMother?.motherFirstName || + profileFamilyMother?.motherLastName + ? `${profileFamilyMother?.motherPrefix ?? ""} ${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() : null, - RetireDate: - profiles.dateRetireLaw != null - ? Extension.ToThaiNumber(profiles.dateRetireLaw.toString()) - : "", - // AvatarId: profiles?.avatar ?? null, - }, - ]; + OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + Division: "", + Institute: "", + StartDate: profiles?.dateStart, + AppointDate: profiles?.dateAppoint ?? "", + BirthDate: profiles?.birthDate + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) + : null, + RetireDate: + profiles.dateRetireLaw != null + ? Extension.ToThaiNumber(profiles.dateRetireLaw.toString()) + : "", + // AvatarId: profiles?.avatar ?? null, + }; const certs = await this.certificateRepository.find({ where: { profileId: id }, @@ -384,12 +382,12 @@ export class ProfileController extends Controller { where: { profileId: id }, }); const Training = trainings.map((item) => ({ - Institute: item.department ?? null, - Start: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate).toString()) ?? null, - End: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate).toString()) ?? null, + Institute: item.department ?? "", + Start: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate).toString()) ?? "", + End: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate).toString()) ?? "", Level: "", Degree: "", - Field: item.place ?? null, + Field: item.place ?? "", })); const disciplines = await this.disciplineRepository.find({ @@ -408,12 +406,12 @@ export class ProfileController extends Controller { where: { profileId: id }, }); const Education = educations.map((item) => ({ - Institute: item.institute ?? null, + Institute: item.institute ?? "", Start: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()) ?? null, End: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()) ?? null, - Level: item.educationLevel ?? null, - Degree: item.degree ?? null, - Field: item.field ?? null, + Level: item.educationLevel ?? "", + Degree: item.degree ?? "", + Field: item.field ?? "", })); const salarys = await this.salaryRepository.find({ select: [ @@ -445,7 +443,7 @@ export class ProfileController extends Controller { OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, })); return new HttpSuccess({ - Profile, + Profile: [Profile], Cert, Training, Discipline,