From 3a258897fbe0a2b7604ae0a4c58a2f06ebc8ae3b Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Wed, 29 May 2024 14:20:06 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20Extension.ToThaiNumber=20=E0=B9=83=E0=B8=99=20profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 60 ++++++++++++++++------------ 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 17796845..9d68cf03 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -302,20 +302,25 @@ export class ProfileController extends Controller { const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; const Profile = { - CitizenId: profiles?.citizenId ?? null, + 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 ? new Date(profiles.birthDate).getDate().toString() : null, + 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 - ? new Date(profiles.birthDate).getMonth() + (1).toString() + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString()) : null, // Months are zero-based - BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear().toString() : null, + BirthYear: profiles?.birthDate + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString()) + : null, BirthYearText: profiles.birthDate != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) @@ -326,24 +331,21 @@ export class ProfileController extends Controller { Province: "", Telephone: profiles?.telephoneNumber ?? null, CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, - CouplePrefix: - profileFamilyCouple?.couplePrefix != null ? profileFamilyCouple.couplePrefix : "", + CouplePrefix: profileFamilyCouple?.couplePrefix ?? "", CoupleFullName: profileFamilyCouple?.couplePrefix || profileFamilyCouple?.coupleFirstName || profileFamilyCouple?.coupleLastNameOld ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() : null, - FatherPrefix: - profileFamilyFather?.fatherPrefix != null ? profileFamilyFather.fatherPrefix : "", + FatherPrefix: profileFamilyFather?.fatherPrefix ?? "", FatherFullName: profileFamilyFather?.fatherPrefix || profileFamilyFather?.fatherFirstName || profileFamilyFather?.fatherLastName ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() : null, - MotherPrefix: - profileFamilyMother?.motherPrefix != null ? profileFamilyMother.motherPrefix : "", + MotherPrefix: profileFamilyMother?.motherPrefix ?? "", MotherFullName: profileFamilyMother?.motherPrefix || profileFamilyMother?.motherFirstName || @@ -355,8 +357,13 @@ export class ProfileController extends Controller { Institute: "", StartDate: profiles?.dateStart, AppointDate: profiles?.dateAppoint, - BirthDate: profiles?.birthDate ? Extension.ToThaiShortDate(profiles.birthDate) : null, - RetireDate: profiles?.dateRetireLaw, + BirthDate: profiles?.birthDate + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) + : null, + RetireDate: + profiles.dateRetireLaw != null + ? Extension.ToThaiNumber(profiles.dateRetireLaw.toString()) + : "", // AvatarId: profiles?.avatar ?? null, }; @@ -367,20 +374,20 @@ export class ProfileController extends Controller { const Cert = certs.map((item) => ({ CertificateType: item.certificateType ?? null, Issuer: item.issuer ?? null, - CertificateNo: item.certificateNo ?? null, - IssueDate: Extension.ToThaiShortDate(item.issueDate) ?? null, + CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null, + IssueDate: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.issueDate)) ?? null, })); const trainings = await this.trainingRepository.find({ select: ["startDate", "endDate", "place", "department"], where: { profileId: id }, }); const Training = trainings.map((item) => ({ - institute: item.department ?? null, - start: Extension.ToThaiShortDate(item.startDate).toString() ?? null, - end: Extension.ToThaiShortDate(item.endDate).toString() ?? null, - level: "", - degree: "", - field: item.place ?? null, + Institute: item.department ?? null, + Start: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate).toString()) ?? null, + End: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate).toString()) ?? null, + Level: "", + Degree: "", + Field: item.place ?? null, })); const disciplines = await this.disciplineRepository.find({ @@ -388,7 +395,8 @@ export class ProfileController extends Controller { where: { profileId: id }, }); const Discipline = disciplines.map((item) => ({ - DisciplineYear: new Date(item.refCommandDate).getFullYear().toString() ?? null, + DisciplineYear: + Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ?? null, DisciplineDetail: item.detail ?? null, RefNo: item.refCommandNo ?? null, })); @@ -399,8 +407,8 @@ export class ProfileController extends Controller { }); const Education = educations.map((item) => ({ Institute: item.institute ?? null, - Start: new Date(item.startDate).getFullYear().toString() ?? null, - End: new Date(item.endDate).getFullYear().toString() ?? null, + 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, @@ -419,7 +427,7 @@ export class ProfileController extends Controller { }); const Salary = salarys.map((item) => ({ - SalaryDate: Extension.ToThaiShortDate(item.date) ?? null, + SalaryDate: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.date)) ?? null, Position: item.position ?? null, PosNo: item.posNo ?? null, Salary: "", @@ -428,7 +436,9 @@ export class ProfileController extends Controller { PositionType: item.positionType ?? null, PositionLevel: item.positionLevel ?? null, PositionAmount: - item.positionSalaryAmount == null ? null : item.positionSalaryAmount.toString(), + item.positionSalaryAmount == null + ? null + : Extension.ToThaiNumber(item.positionSalaryAmount.toString()), FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, }));