From 8dfb093a9e1c93866e2aea07890349911cee8134 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 13 Dec 2024 16:06:19 +0700 Subject: [PATCH 1/2] no message --- .../OrganizationDotnetController.ts | 110 +++++++++++++++++- 1 file changed, 106 insertions(+), 4 deletions(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 006cf6aa..0a2e40a5 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -2758,12 +2758,63 @@ export class OrganizationDotnetController extends Controller { @Request() req: RequestWithUser, @Body() body: { - node: string; + node: number; nodeId: string; + isAll: boolean; }, ) { + let typeCondition: any = {}; + if (body.isAll == false) { + if (body.node === 0) { + typeCondition = { + orgRootId: body.nodeId, + orgChild1Id: IsNull(), + }; + } else if (body.node === 1) { + typeCondition = { + orgChild1Id: body.nodeId, + orgChild2Id: IsNull(), + }; + } else if (body.node === 2) { + typeCondition = { + orgChild2Id: body.nodeId, + orgChild3Id: IsNull(), + }; + } else if (body.node === 3) { + typeCondition = { + orgChild3Id: body.nodeId, + orgChild4Id: IsNull(), + }; + } else if (body.node === 4) { + typeCondition = { + orgChild4Id: body.nodeId, + }; + } + } else { + if (body.node === 0) { + typeCondition = { + orgRootId: body.nodeId, + }; + } else if (body.node === 1) { + typeCondition = { + orgChild1Id: body.nodeId, + }; + } else if (body.node === 2) { + typeCondition = { + orgChild2Id: body.nodeId, + }; + } else if (body.node === 3) { + typeCondition = { + orgChild3Id: body.nodeId, + }; + } else if (body.node === 4) { + typeCondition = { + orgChild4Id: body.nodeId, + }; + } + } const profile = await this.profileRepo.find({ - where: { keycloak: Not(IsNull()) || Not(""), isLeave: false }, + where: { keycloak: Not(IsNull()) || Not(""), isLeave: false, current_holders: typeCondition }, relations: [ "current_holders", "current_holders.orgRoot", @@ -2831,12 +2882,63 @@ export class OrganizationDotnetController extends Controller { @Request() req: RequestWithUser, @Body() body: { - node: string; + node: number; nodeId: string; + isAll: boolean; }, ) { + let typeCondition: any = {}; + if (body.isAll == false) { + if (body.node === 0) { + typeCondition = { + orgRootId: body.nodeId, + orgChild1Id: IsNull(), + }; + } else if (body.node === 1) { + typeCondition = { + orgChild1Id: body.nodeId, + orgChild2Id: IsNull(), + }; + } else if (body.node === 2) { + typeCondition = { + orgChild2Id: body.nodeId, + orgChild3Id: IsNull(), + }; + } else if (body.node === 3) { + typeCondition = { + orgChild3Id: body.nodeId, + orgChild4Id: IsNull(), + }; + } else if (body.node === 4) { + typeCondition = { + orgChild4Id: body.nodeId, + }; + } + } else { + if (body.node === 0) { + typeCondition = { + orgRootId: body.nodeId, + }; + } else if (body.node === 1) { + typeCondition = { + orgChild1Id: body.nodeId, + }; + } else if (body.node === 2) { + typeCondition = { + orgChild2Id: body.nodeId, + }; + } else if (body.node === 3) { + typeCondition = { + orgChild3Id: body.nodeId, + }; + } else if (body.node === 4) { + typeCondition = { + orgChild4Id: body.nodeId, + }; + } + } const profile = await this.profileEmpRepo.find({ - where: { keycloak: Not(IsNull()) || Not(""), isLeave: false }, + where: { keycloak: Not(IsNull()) || Not(""), isLeave: false, current_holders: typeCondition }, relations: [ "current_holders", "current_holders.orgRoot", From 139cb542b078ee72267a8b3c6f07dc5e10b3774d Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 13 Dec 2024 17:42:32 +0700 Subject: [PATCH 2/2] add position --- src/controllers/OrganizationDotnetController.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 0a2e40a5..23046b3b 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -2611,7 +2611,8 @@ export class OrganizationDotnetController extends Controller { currentZipCode: item.currentZipCode, dutyTimeId: item.dutyTimeId, dutyTimeEffectiveDate: item.dutyTimeEffectiveDate, - positionLevel: item.profileSalary.length > 0 ? item.profileSalary[0].positionLevel : null, + positionLevel: item.posLevel?.posLevelName ?? null, + positionType: item.posType?.posTypeName ?? null, posNo: shortName, }; }), @@ -2738,7 +2739,8 @@ export class OrganizationDotnetController extends Controller { currentZipCode: item.currentZipCode, dutyTimeId: item.dutyTimeId, dutyTimeEffectiveDate: item.dutyTimeEffectiveDate, - positionLevel: item.profileSalary.length > 0 ? item.profileSalary[0].positionLevel : null, + positionLevel: item.posLevel?.posLevelName ?? null, + positionType: item.posType?.posTypeName ?? null, posNo: shortName, }; }), @@ -2816,6 +2818,8 @@ export class OrganizationDotnetController extends Controller { const profile = await this.profileRepo.find({ where: { keycloak: Not(IsNull()) || Not(""), isLeave: false, current_holders: typeCondition }, relations: [ + "posType", + "posLevel", "current_holders", "current_holders.orgRoot", "current_holders.orgChild1", @@ -2864,6 +2868,9 @@ export class OrganizationDotnetController extends Controller { lastName: item.lastName, keycloak: item.keycloak, posNo: shortName, + position: item.position, + positionLevel: item.posLevel?.posLevelName ?? null, + positionType: item.posType?.posTypeName ?? null, }; }), ); @@ -2940,6 +2947,8 @@ export class OrganizationDotnetController extends Controller { const profile = await this.profileEmpRepo.find({ where: { keycloak: Not(IsNull()) || Not(""), isLeave: false, current_holders: typeCondition }, relations: [ + "posType", + "posLevel", "current_holders", "current_holders.orgRoot", "current_holders.orgChild1", @@ -2989,6 +2998,9 @@ export class OrganizationDotnetController extends Controller { citizenId: item.citizenId, keycloak: item.keycloak, posNo: shortName, + position: item.position, + positionLevel: item.posLevel?.posLevelName ?? null, + positionType: item.posType?.posTypeName ?? null, }; }), );