เพิ่ม Extension.ToThaiNumber ใน profile

This commit is contained in:
AnandaTon 2024-05-29 14:20:06 +07:00
parent 7c1bcebcb8
commit 3a258897fb

View file

@ -302,20 +302,25 @@ export class ProfileController extends Controller {
const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; const _child4 = child4 ? `${child4.orgChild4Name}/` : "";
const Profile = { const Profile = {
CitizenId: profiles?.citizenId ?? null, CitizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
Prefix: profiles?.prefix != null ? profiles.prefix : "", Prefix: profiles?.prefix != null ? profiles.prefix : "",
FirstName: profiles?.firstName != null ? profiles.firstName : "", FirstName: profiles?.firstName != null ? profiles.firstName : "",
LastName: profiles?.lastName != null ? profiles.lastName : "", LastName: profiles?.lastName != null ? profiles.lastName : "",
FullName: `${profiles?.prefix} ${profiles?.firstName} ${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: BirthDayText:
profiles.birthDate != null profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
: "", : "",
BirthMonth: profiles?.birthDate BirthMonth: profiles?.birthDate
? new Date(profiles.birthDate).getMonth() + (1).toString() ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString())
: null, // Months are zero-based : 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: BirthYearText:
profiles.birthDate != null profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
@ -326,24 +331,21 @@ export class ProfileController extends Controller {
Province: "", Province: "",
Telephone: profiles?.telephoneNumber ?? null, Telephone: profiles?.telephoneNumber ?? null,
CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
CouplePrefix: CouplePrefix: profileFamilyCouple?.couplePrefix ?? "",
profileFamilyCouple?.couplePrefix != null ? profileFamilyCouple.couplePrefix : "",
CoupleFullName: CoupleFullName:
profileFamilyCouple?.couplePrefix || profileFamilyCouple?.couplePrefix ||
profileFamilyCouple?.coupleFirstName || profileFamilyCouple?.coupleFirstName ||
profileFamilyCouple?.coupleLastNameOld profileFamilyCouple?.coupleLastNameOld
? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim()
: null, : null,
FatherPrefix: FatherPrefix: profileFamilyFather?.fatherPrefix ?? "",
profileFamilyFather?.fatherPrefix != null ? profileFamilyFather.fatherPrefix : "",
FatherFullName: FatherFullName:
profileFamilyFather?.fatherPrefix || profileFamilyFather?.fatherPrefix ||
profileFamilyFather?.fatherFirstName || profileFamilyFather?.fatherFirstName ||
profileFamilyFather?.fatherLastName profileFamilyFather?.fatherLastName
? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
: null, : null,
MotherPrefix: MotherPrefix: profileFamilyMother?.motherPrefix ?? "",
profileFamilyMother?.motherPrefix != null ? profileFamilyMother.motherPrefix : "",
MotherFullName: MotherFullName:
profileFamilyMother?.motherPrefix || profileFamilyMother?.motherPrefix ||
profileFamilyMother?.motherFirstName || profileFamilyMother?.motherFirstName ||
@ -355,8 +357,13 @@ export class ProfileController extends Controller {
Institute: "", Institute: "",
StartDate: profiles?.dateStart, StartDate: profiles?.dateStart,
AppointDate: profiles?.dateAppoint, AppointDate: profiles?.dateAppoint,
BirthDate: profiles?.birthDate ? Extension.ToThaiShortDate(profiles.birthDate) : null, BirthDate: profiles?.birthDate
RetireDate: profiles?.dateRetireLaw, ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate))
: null,
RetireDate:
profiles.dateRetireLaw != null
? Extension.ToThaiNumber(profiles.dateRetireLaw.toString())
: "",
// AvatarId: profiles?.avatar ?? null, // AvatarId: profiles?.avatar ?? null,
}; };
@ -367,20 +374,20 @@ export class ProfileController extends Controller {
const Cert = certs.map((item) => ({ const Cert = certs.map((item) => ({
CertificateType: item.certificateType ?? null, CertificateType: item.certificateType ?? null,
Issuer: item.issuer ?? null, Issuer: item.issuer ?? null,
CertificateNo: item.certificateNo ?? null, CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null,
IssueDate: Extension.ToThaiShortDate(item.issueDate) ?? null, IssueDate: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.issueDate)) ?? null,
})); }));
const trainings = await this.trainingRepository.find({ const trainings = await this.trainingRepository.find({
select: ["startDate", "endDate", "place", "department"], select: ["startDate", "endDate", "place", "department"],
where: { profileId: id }, where: { profileId: id },
}); });
const Training = trainings.map((item) => ({ const Training = trainings.map((item) => ({
institute: item.department ?? null, Institute: item.department ?? null,
start: Extension.ToThaiShortDate(item.startDate).toString() ?? null, Start: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate).toString()) ?? null,
end: Extension.ToThaiShortDate(item.endDate).toString() ?? null, End: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate).toString()) ?? null,
level: "", Level: "",
degree: "", Degree: "",
field: item.place ?? null, Field: item.place ?? null,
})); }));
const disciplines = await this.disciplineRepository.find({ const disciplines = await this.disciplineRepository.find({
@ -388,7 +395,8 @@ export class ProfileController extends Controller {
where: { profileId: id }, where: { profileId: id },
}); });
const Discipline = disciplines.map((item) => ({ 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, DisciplineDetail: item.detail ?? null,
RefNo: item.refCommandNo ?? null, RefNo: item.refCommandNo ?? null,
})); }));
@ -399,8 +407,8 @@ export class ProfileController extends Controller {
}); });
const Education = educations.map((item) => ({ const Education = educations.map((item) => ({
Institute: item.institute ?? null, Institute: item.institute ?? null,
Start: new Date(item.startDate).getFullYear().toString() ?? null, Start: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()) ?? null,
End: new Date(item.endDate).getFullYear().toString() ?? null, End: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()) ?? null,
Level: item.educationLevel ?? null, Level: item.educationLevel ?? null,
Degree: item.degree ?? null, Degree: item.degree ?? null,
Field: item.field ?? null, Field: item.field ?? null,
@ -419,7 +427,7 @@ export class ProfileController extends Controller {
}); });
const Salary = salarys.map((item) => ({ const Salary = salarys.map((item) => ({
SalaryDate: Extension.ToThaiShortDate(item.date) ?? null, SalaryDate: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.date)) ?? null,
Position: item.position ?? null, Position: item.position ?? null,
PosNo: item.posNo ?? null, PosNo: item.posNo ?? null,
Salary: "", Salary: "",
@ -428,7 +436,9 @@ export class ProfileController extends Controller {
PositionType: item.positionType ?? null, PositionType: item.positionType ?? null,
PositionLevel: item.positionLevel ?? null, PositionLevel: item.positionLevel ?? null,
PositionAmount: PositionAmount:
item.positionSalaryAmount == null ? null : item.positionSalaryAmount.toString(), item.positionSalaryAmount == null
? null
: Extension.ToThaiNumber(item.positionSalaryAmount.toString()),
FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`,
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
})); }));