From 85252f05c3b0ddb43fa31a38f0155996175ffb95 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 18 Apr 2024 11:59:43 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C=20org?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrganizationUnauthorizeController.ts | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index 1c43c7d5..35f37b32 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -640,6 +640,10 @@ export class OrganizationUnauthorizeController extends Controller { .createQueryBuilder("profile") .leftJoinAndSelect("profile.current_holders", "current_holders") .leftJoinAndSelect("current_holders.orgRoot", "orgRoot") + .leftJoinAndSelect("current_holders.orgChild1", "orgChild1") + .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") + .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") + .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.positions", "positions") .leftJoinAndSelect("positions.posExecutive", "posExecutive") .where({ citizenId: id }) @@ -678,12 +682,47 @@ export class OrganizationUnauthorizeController extends Controller { findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null ? null : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; + + const child1 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1; + + const child2 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2; + + const child3 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3; + + const child4 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.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}/` + return new HttpSuccess({ rootId: root == null ? null : root.id, root: root == null ? null : root.orgRootName, orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: findRevision.id, profileId: findProfile.id, + org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName}`, type: "OFFICER", rank: findProfile.rank, prefix: findProfile.prefix, @@ -716,8 +755,12 @@ export class OrganizationUnauthorizeController extends Controller { .createQueryBuilder("profile") .leftJoinAndSelect("profile.current_holders", "current_holders") .leftJoinAndSelect("current_holders.orgRoot", "orgRoot") + .leftJoinAndSelect("current_holders.orgChild1", "orgChild1") + .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") + .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") + .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.positions", "positions") - .leftJoinAndSelect("positions.posExecutive", "posExecutive") + // .leftJoinAndSelect("positions.posExecutive", "posExecutive") .where({ citizenId: id }) .getOne(); if (!findProfile) { @@ -731,12 +774,46 @@ export class OrganizationUnauthorizeController extends Controller { ? null : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; + const child1 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1; + + const child2 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2; + + const child3 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3; + + const child4 = + findProfile.current_holders == null || + findProfile.current_holders.length == 0 || + findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : findProfile.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}/` + return new HttpSuccess({ rootId: root == null ? null : root.id, root: root == null ? null : root.orgRootName, orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: findRevision.id, profileId: findProfile.id, + org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName}`, type: "EMPLOYEE", rank: findProfile.rank, prefix: findProfile.prefix,