From 86fd868adf6c41ef7fbdcdda8674faa2dc73256f Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 23 May 2024 15:28:49 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20query=20?= =?UTF-8?q?report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 40 +++++++++++--------- src/controllers/ProfileEmployeeController.ts | 40 +++++++++++--------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 2c70bf6b..243dc557 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -43,6 +43,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee"; import { Province } from "../entities/Province"; import { District } from "../entities/District"; import { SubDistrict } from "../entities/SubDistrict"; +import Extension from "../interfaces/extension"; @Route("api/v1/org/profile") @Tags("Profile") @@ -132,6 +133,11 @@ export class ProfileController extends Controller { ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; + let _regisAddres = profile && profile.registrationAddress != null ? profile.registrationAddress : "" + let _subDistrict = subDistrict && subDistrict.name != null ? `\r\nตำบล/แขวง ${province?.name}` : "" + let _district = district && district.name != null ? `\r\nเขต/อำเภอ ${district?.name}` : "" + let _province = province && province.name != null ? `\r\nจังหวัด ${province?.name}` : "" + let registrationZipCode = profile && profile.registrationZipCode != null ? ` รหัสไปรษณีย์ ${profile.registrationZipCode}` : "" let _root = root == null || root == undefined ? "" : `${root.orgRootName}`; let _child1 = child1 == null || child1 == undefined ? "" : `${child1.orgChild1Name}/`; let _child2 = child2 == null || child2 == undefined ? "" : `${child2.orgChild2Name}/`; @@ -140,24 +146,24 @@ export class ProfileController extends Controller { const mapData = { Id: profile.id, - CitizenId: profile.citizenId, - Prefix: profile.prefix, - FirstName: profile.firstName, - LastName: profile.lastName, - DateOfBirth: profile.birthDate, - DateRetire: profile.dateRetire, - RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`, - SalaryAmount: profile.profileSalary.length > 0 - ? profile.profileSalary[0].amount.toString() - : null, - Education: profile.profileEducations.length > 0 + CitizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", + Prefix: profile.prefix != null ? profile.prefix : "", + FirstName: profile.firstName != null ? profile.firstName : "", + LastName: profile.lastName != null ? profile.lastName : "", + DateOfBirth: profile.birthDate != null ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.birthDate)) : "", + DateRetire: profile.dateRetire != null ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateRetire)) : "", + RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, + SalaryAmount: profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null + ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) + : "", + Education: profile.profileEducations.length > 0 && profile.profileEducations[profile.profileEducations.length-1].institute != null ? profile.profileEducations[profile.profileEducations.length-1].institute - : null, - AppointText: profile.dateAppoint, - SalaryDate: profile.profileSalary.length > 0 - ? profile.profileSalary[0].date - : null, - PositionName: profile.position, + : "", + AppointText: profile.dateAppoint != null ? profile.dateAppoint : "", + SalaryDate: profile.profileSalary.length > 0 && profile.profileSalary[0].date != null + ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date)) + : "", + PositionName: profile.position != null ? profile.position : "", OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, } diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index ce1b30ae..8ecef4e4 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -35,6 +35,7 @@ import { Position } from "../entities/Position"; import { Province } from "../entities/Province"; import { District } from "../entities/District"; import { SubDistrict } from "../entities/SubDistrict"; +import Extension from "../interfaces/extension"; @Route("api/v1/org/profile-employee") @Tags("ProfileEmployee") @@ -122,6 +123,11 @@ export class ProfileEmployeeController extends Controller { ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; + let _regisAddres = profile && profile.registrationAddress != null ? profile.registrationAddress : "" + let _subDistrict = subDistrict && subDistrict.name != null ? `\r\nตำบล/แขวง ${province?.name}` : "" + let _district = district && district.name != null ? `\r\nเขต/อำเภอ ${district?.name}` : "" + let _province = province && province.name != null ? `\r\nจังหวัด ${province?.name}` : "" + let registrationZipCode = profile && profile.registrationZipCode != null ? ` รหัสไปรษณีย์ ${profile.registrationZipCode}` : "" let _root = root == null || root == undefined ? "" : `${root.orgRootName}`; let _child1 = child1 == null || child1 == undefined ? "" : `${child1.orgChild1Name}/`; let _child2 = child2 == null || child2 == undefined ? "" : `${child2.orgChild2Name}/`; @@ -130,24 +136,24 @@ export class ProfileEmployeeController extends Controller { const mapData = { Id: profile.id, - CitizenId: profile.citizenId, - Prefix: profile.prefix, - FirstName: profile.firstName, - LastName: profile.lastName, - DateOfBirth: profile.birthDate, - DateRetire: profile.dateRetire, - RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`, - SalaryAmount: profile.profileSalarys.length > 0 - ? profile.profileSalarys[0].amount - : null, - Education: profile.profileEducations.length > 0 + CitizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", + Prefix: profile.prefix != null ? profile.prefix : "", + FirstName: profile.firstName != null ? profile.firstName : "", + LastName: profile.lastName != null ? profile.lastName : "", + DateOfBirth: profile.birthDate != null ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.birthDate)) : "", + DateRetire: profile.dateRetire != null ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateRetire)) : "", + RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, + SalaryAmount: profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null + ? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString()) + : "", + Education: profile.profileEducations.length > 0 && profile.profileEducations[profile.profileEducations.length-1].institute != null ? profile.profileEducations[profile.profileEducations.length-1].institute - : null, - AppointText: profile.dateAppoint, - SalaryDate: profile.profileSalarys.length > 0 - ? profile.profileSalarys[0].date - : null, - PositionName: profile.position, + : "", + AppointText: profile.dateAppoint != null ? profile.dateAppoint : "", + SalaryDate: profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null + ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalarys[0].date)) + : "", + PositionName: profile.position != null ? profile.position : "", OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, }