From 8cf13b86908f8b4579390955c9c656c8627ce5c4 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 31 Mar 2025 11:25:25 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20return=20=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=94=E0=B8=B1=E0=B8=9A=E0=B8=95=E0=B8=B3?= =?UTF-8?q?=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87,=20=E0=B8=AA?= =?UTF-8?q?=E0=B8=B1=E0=B8=87=E0=B8=81=E0=B8=B1=E0=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrganizationDotnetController.ts | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index cb87c807..22354c10 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -500,7 +500,26 @@ export class OrganizationDotnetController extends Controller { } } } - + let positionLeaveName = profile.posLevel?.posLevelName ?? null + const _profileCurrent = profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft === false && + x.orgRevision?.orgRevisionIsCurrent === true + ); + let oc = ""; + if (_profileCurrent != null) { + if (_profileCurrent.orgChild1Id === null) { + oc = _profileCurrent.orgRoot?.orgRootName; + } else if (_profileCurrent.orgChild2Id === null) { + oc = `${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; + } else if (_profileCurrent.orgChild3Id === null) { + oc = `${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; + } else if (_profileCurrent.orgChild4Id === null) { + oc = `${_profileCurrent.orgChild3?.orgChild3Name} ${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`;; + } else { + oc = `${_profileCurrent.orgChild4?.orgChild4Name}` + } + } const mapProfile = { id: profile.id, avatar: profile.avatar, @@ -621,6 +640,8 @@ export class OrganizationDotnetController extends Controller { profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null, profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null, profileType: "EMPLOYEE", + positionLeaveName: positionLeaveName, + oc: oc, }; return new HttpSuccess(mapProfile); @@ -794,6 +815,29 @@ export class OrganizationDotnetController extends Controller { } } + let positionLeaveName = profile.posType != null && profile.posLevel != null + && (profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ") + ? `${profile.posType?.posTypeName ?? ""}${profile.posLevel?.posLevelName ?? ""}` + : profile.posLevel?.posLevelName ?? null + const _profileCurrent = profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft === false && + x.orgRevision?.orgRevisionIsCurrent === true + ); + let oc = ""; + if (_profileCurrent != null) { + if (_profileCurrent.orgChild1Id === null) { + oc = _profileCurrent.orgRoot?.orgRootName; + } else if (_profileCurrent.orgChild2Id === null) { + oc = `${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; + } else if (_profileCurrent.orgChild3Id === null) { + oc = `${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; + } else if (_profileCurrent.orgChild4Id === null) { + oc = `${_profileCurrent.orgChild3?.orgChild3Name} ${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`;; + } else { + oc = `${_profileCurrent.orgChild4?.orgChild4Name}` + } + } const mapProfile = { id: profile.id, avatar: profile.avatar, @@ -914,6 +958,8 @@ export class OrganizationDotnetController extends Controller { profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null, profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null, profileType: "OFFICER", + positionLeaveName: positionLeaveName, + oc: oc, }; return new HttpSuccess(mapProfile);