From 635ca1683c39780b2ed049437328f01cfb9fdedf Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Wed, 14 May 2025 15:03:20 +0700 Subject: [PATCH 1/2] add isDeputy --- src/controllers/OrganizationController.ts | 1 + src/controllers/WorkflowController.ts | 38 ++++++++++------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 8bd9905d..ce0b5d8d 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -7170,6 +7170,7 @@ export class OrganizationController extends Controller { return { orgTreeId: orgRoot.id, orgLevel: 0, + isDeputy: orgRoot.isDeputy, orgName: orgRoot.orgRootName, orgTreeName: orgRoot.orgRootName, orgTreeShortName: orgRoot.orgRootShortName, diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index bff33d56..766263a5 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -50,7 +50,7 @@ export class WorkflowController extends Controller { sysName: string; posLevelName: string; posTypeName: string; - fullName?: string|null + fullName?: string | null; }, ) { let profileType = "OFFICER"; @@ -1103,7 +1103,7 @@ export class WorkflowController extends Controller { orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, current_holderId: profile.id, }, - relations: ["orgChild1"], + relations: ["orgChild1", "orgRoot"], }); const profileDirector = await this.posMasterRepo.findOne({ where: { @@ -1116,12 +1116,14 @@ export class WorkflowController extends Controller { isOfficer: false, isStaff: false, isDirector: profileDirector?.isDirector ?? false, + isDeputy: false, }); let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer, isDirector: profileDirector?.isDirector ?? false, + isDeputy: profileOfficer?.orgRoot?.isDeputy ?? false, }); } @@ -1265,7 +1267,6 @@ export class WorkflowController extends Controller { refId: string[]; }, ) { - const _posMaster = await this.posMasterRepo.find({ where: { orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, @@ -1284,12 +1285,12 @@ export class WorkflowController extends Controller { current_holder: Not(IsNull()), posMasterAssigns: { assignId: system.trim().toUpperCase() }, })); - + const posMaster = await this.posMasterRepo.find({ where: _data, relations: ["current_holder"], }); - + const data = posMaster.map((x) => ({ id: x.current_holder.id, citizenId: x.current_holder.citizenId, @@ -1297,7 +1298,7 @@ export class WorkflowController extends Controller { firstName: x.current_holder.firstName, lastName: x.current_holder.lastName, })); - + return new HttpSuccess(data); } /** @@ -1315,12 +1316,11 @@ export class WorkflowController extends Controller { refId: string[]; }, ) { - const profileWithKc = await this.profileRepo.find({ - where:{ - keycloak: In(body.refId) - } - }) + where: { + keycloak: In(body.refId), + }, + }); const profileIds = profileWithKc.map((p) => p.id); @@ -1332,14 +1332,8 @@ export class WorkflowController extends Controller { }, current_holderId: In(profileIds), }, - select: [ - "orgRootId", - "orgChild1Id", - "orgChild2Id", - "orgChild3Id", - "orgChild4Id", - ], - }) + select: ["orgRootId", "orgChild1Id", "orgChild2Id", "orgChild3Id", "orgChild4Id"], + }); const _data: any = _posMaster.map((x) => ({ orgRootId: x.orgRootId, @@ -1351,12 +1345,12 @@ export class WorkflowController extends Controller { current_holder: Not(IsNull()), posMasterAssigns: { assignId: system.trim().toUpperCase() }, })); - + const posMaster = await this.posMasterRepo.find({ where: _data, relations: ["current_holder"], }); - + const data = posMaster.map((x) => ({ id: x.current_holder.id, keycloak: x.current_holder.keycloak, @@ -1365,7 +1359,7 @@ export class WorkflowController extends Controller { firstName: x.current_holder.firstName, lastName: x.current_holder.lastName, })); - + return new HttpSuccess(data); } } From 18b1171c34028877befd7f2106bab2b8248505b9 Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Wed, 14 May 2025 15:30:22 +0700 Subject: [PATCH 2/2] add isduty --- src/controllers/OrganizationController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index ce0b5d8d..18465656 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -7161,6 +7161,7 @@ export class OrganizationController extends Controller { "orgRoot.orgRootRank", "orgRoot.orgRootRankSub", "orgRoot.responsibility", + "orgRoot.isDeputy", ]) .orderBy("orgRoot.orgRootOrder", "ASC") .getMany();