From b1b9700e4064936a0bd5734c77d4293054f8606e Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 4 Apr 2025 10:07:34 +0700 Subject: [PATCH] org \n 2 --- .../PermissionProfileController.ts | 30 ++++++++----- src/controllers/ProfileController.ts | 44 +++++++++++++------ src/controllers/ProfileEmployeeController.ts | 22 +++++++--- .../ProfileEmployeeTempController.ts | 23 +++++++--- .../ProfileGovernmentController.ts | 6 +-- .../ProfileGovernmentEmployeeController.ts | 6 +-- ...ProfileGovernmentEmployeeTempController.ts | 6 +-- 7 files changed, 90 insertions(+), 47 deletions(-) diff --git a/src/controllers/PermissionProfileController.ts b/src/controllers/PermissionProfileController.ts index 4240f5db..f20d2d9a 100644 --- a/src/controllers/PermissionProfileController.ts +++ b/src/controllers/PermissionProfileController.ts @@ -221,10 +221,11 @@ export class PermissionProfileController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; - let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`; - let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`; - let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`; - let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`; + let _root = root?.orgRootName; + let _child1 =child1?.orgChild1Name; + let _child2 =child2?.orgChild2Name; + let _child3 =child3?.orgChild3Name; + let _child4 =child4?.orgChild4Name; return { id: _data.id, @@ -234,7 +235,11 @@ export class PermissionProfileController extends Controller { rank: _data.rank, firstName: _data.firstName, lastName: _data.lastName, - org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, + org: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), posNo: shortName, position: _data.position, posType: _data.posType == null ? null : _data.posType.posTypeName, @@ -430,10 +435,11 @@ export class PermissionProfileController extends Controller { : _data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild4; - let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`; - let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`; - let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`; - let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`; + let _root = root?.orgRootName; + let _child1 =child1?.orgChild1Name; + let _child2 =child2?.orgChild2Name; + let _child3 =child3?.orgChild3Name; + let _child4 =child4?.orgChild4Name; return { id: _data.id, @@ -448,7 +454,11 @@ export class PermissionProfileController extends Controller { rank: _data.profileTree.rank, firstName: _data.profileTree.firstName, lastName: _data.profileTree.lastName, - org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, + org: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), posNo: shortName, position: _data.profileTree.position, posType: _data.profileTree.posType == null ? null : _data.profileTree.posType.posTypeName, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index cb9e5466..7e5420a6 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -553,11 +553,11 @@ export class ProfileController extends Controller { : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; // Construct org path - const _root = root ? `${root.orgRootName}` : ""; - const _child1 = child1 ? `${child1.orgChild1Name}/` : ""; - const _child2 = child2 ? `${child2.orgChild2Name}/` : ""; - const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; - const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; + let _root = root?.orgRootName; + let _child1 =child1?.orgChild1Name; + let _child2 =child2?.orgChild2Name; + let _child3 =child3?.orgChild3Name; + let _child4 =child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ where: { profileId: id }, @@ -712,7 +712,11 @@ export class ProfileController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + ocFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -801,7 +805,11 @@ export class ProfileController extends Controller { prefix: profiles?.prefix != null ? profiles.prefix : "", firstName: profiles?.firstName != null ? profiles.firstName : "", lastName: profiles?.lastName != null ? profiles.lastName : "", - ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + ocFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", @@ -1033,11 +1041,11 @@ export class ProfileController extends Controller { : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; // Construct org path - const _root = root ? `${root.orgRootName}` : ""; - const _child1 = child1 ? `${child1.orgChild1Name}/` : ""; - const _child2 = child2 ? `${child2.orgChild2Name}/` : ""; - const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; - const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; + let _root = root?.orgRootName; + let _child1 =child1?.orgChild1Name; + let _child2 =child2?.orgChild2Name; + let _child3 =child3?.orgChild3Name; + let _child4 =child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ where: { profileId: id }, @@ -1208,7 +1216,11 @@ export class ProfileController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + ocFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -1643,7 +1655,11 @@ export class ProfileController extends Controller { ? Extension.ToThaiNumber(profiles.amountSpecial.toLocaleString()) : "", salarySum: sum, - ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + ocFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index d24e510c..d45f68a9 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -539,11 +539,11 @@ export class ProfileEmployeeController extends Controller { : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; // Construct org path - const _root = root ? `${root.orgRootName}` : ""; - const _child1 = child1 ? `${child1.orgChild1Name}/` : ""; - const _child2 = child2 ? `${child2.orgChild2Name}/` : ""; - const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; - const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; + let _root = root?.orgRootName; + let _child1 =child1?.orgChild1Name; + let _child2 =child2?.orgChild2Name; + let _child3 =child3?.orgChild3Name; + let _child4 =child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ where: { profileEmployeeId: id }, @@ -698,7 +698,11 @@ export class ProfileEmployeeController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + OcFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -787,7 +791,11 @@ export class ProfileEmployeeController extends Controller { prefix: profiles?.prefix != null ? profiles.prefix : "", firstName: profiles?.firstName != null ? profiles.firstName : "", lastName: profiles?.lastName != null ? profiles.lastName : "", - ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + ocFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 8bc1f37a..9e748964 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -533,11 +533,12 @@ export class ProfileEmployeeTempController extends Controller { : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; // Construct org path - const _root = root ? `${root.orgRootName}` : ""; - const _child1 = child1 ? `${child1.orgChild1Name}/` : ""; - const _child2 = child2 ? `${child2.orgChild2Name}/` : ""; - const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; - const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; + let _root = root?.orgRootName; + let _child1 =child1?.orgChild1Name; + let _child2 =child2?.orgChild2Name; + let _child3 =child3?.orgChild3Name; + let _child4 =child4?.orgChild4Name; + const cert_raw = await this.certificateRepository.find({ where: { profileEmployeeId: id }, @@ -692,7 +693,11 @@ export class ProfileEmployeeTempController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + OcFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -781,7 +786,11 @@ export class ProfileEmployeeTempController extends Controller { prefix: profiles?.prefix != null ? profiles.prefix : "", firstName: profiles?.firstName != null ? profiles.firstName : "", lastName: profiles?.lastName != null ? profiles.lastName : "", - ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + ocFullPath: (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 617faf9a..28b6690e 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -94,7 +94,7 @@ export class ProfileGovernmentHistoryController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { @@ -205,7 +205,7 @@ export class ProfileGovernmentHistoryController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { @@ -299,7 +299,7 @@ export class ProfileGovernmentHistoryController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/n"); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index 5dabc746..d30e9e99 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -90,7 +90,7 @@ export class ProfileGovernmentEmployeeController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { @@ -194,7 +194,7 @@ export class ProfileGovernmentEmployeeController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { @@ -281,7 +281,7 @@ export class ProfileGovernmentEmployeeController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { diff --git a/src/controllers/ProfileGovernmentEmployeeTempController.ts b/src/controllers/ProfileGovernmentEmployeeTempController.ts index 7f72241a..f5a68186 100644 --- a/src/controllers/ProfileGovernmentEmployeeTempController.ts +++ b/src/controllers/ProfileGovernmentEmployeeTempController.ts @@ -85,7 +85,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { @@ -184,7 +184,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) { @@ -271,7 +271,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, ]; - const org = fullNameParts.filter((part) => part !== undefined && part !== null).join(" "); + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("\n"); let orgShortName = ""; if (posMaster != null) { if (posMaster.orgChild1Id === null) {