From d6afe2c8f70de2dade9410ab62f40eb82c5c873f Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 16:22:34 +0700 Subject: [PATCH 1/2] add function find commander --- src/controllers/WorkflowController.ts | 73 ++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 722da33b..17a1a5d7 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -1265,6 +1265,7 @@ export class WorkflowController extends Controller { refId: string[]; }, ) { + const _posMaster = await this.posMasterRepo.find({ where: { orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, @@ -1272,6 +1273,7 @@ export class WorkflowController extends Controller { }, select: ["orgRootId", "orgChild1Id", "orgChild2Id", "orgChild3Id", "orgChild4Id"], }); + const _data: any = _posMaster.map((x) => ({ orgRootId: x.orgRootId, // orgChild1Id: x.orgChild1Id, @@ -1282,11 +1284,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, @@ -1294,6 +1297,74 @@ export class WorkflowController extends Controller { firstName: x.current_holder.firstName, lastName: x.current_holder.lastName, })); + + return new HttpSuccess(data); + } + /** + * API หา กจ ตามระบบด้วย keycloak + * + * @summary หา กจ ตามระบบด้วย keycloak + * + */ + @Post("find/director-with-keycloak/{system}") + async getProfileDirectorByKeycloakIdSystem( + @Request() req: RequestWithUser, + @Path() system: string, + @Body() + body: { + refId: string[]; + }, + ) { + + const profileWithKc = await this.profileRepo.find({ + where:{ + keycloak: In(body.refId) + } + }) + + const profileIds = profileWithKc.map((p) => p.id); + + const _posMaster = await this.posMasterRepo.find({ + where: { + orgRevision: { + orgRevisionIsDraft: false, + orgRevisionIsCurrent: true, + }, + current_holderId: In(profileIds), + }, + select: [ + "orgRootId", + "orgChild1Id", + "orgChild2Id", + "orgChild3Id", + "orgChild4Id", + ], + }) + + const _data: any = _posMaster.map((x) => ({ + orgRootId: x.orgRootId, + // orgChild1Id: x.orgChild1Id, + // orgChild2Id: x.orgChild2Id, + // orgChild3Id: x.orgChild3Id, + // orgChild4Id: x.orgChild4Id, + // isDirector: true, + 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, + prefix: x.current_holder.prefix, + firstName: x.current_holder.firstName, + lastName: x.current_holder.lastName, + })); + return new HttpSuccess(data); } } From cb16fb2c2f512791dcf11413ee06440f0531e6b9 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 22 Apr 2025 18:00:49 +0700 Subject: [PATCH 2/2] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5=E0=B8=A2=E0=B8=99?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4?= =?UTF-8?q?=20>>=20=E0=B8=A3=E0=B8=B9=E0=B8=9B=E0=B8=A0=E0=B8=B2=E0=B8=9E?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2=E0=B9=82=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C=E0=B9=83=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=89=E0=B8=B2=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87=20#1443?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileEmployeeController.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 80581bdd..0f1e10a0 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2018,6 +2018,8 @@ export class ProfileEmployeeController extends Controller { // let _child4 = child4?.orgChild4Name; return { id: _data.id, + avatar: _data.avatar, + avatarName: _data.avatarName, prefix: _data.prefix, rank: _data.rank, firstName: _data.firstName, @@ -2431,6 +2433,8 @@ export class ProfileEmployeeController extends Controller { let _child4 = child4?.orgChild4Name; return { id: _data.id, + avatar: _data.avatar, + avatarName: _data.avatarName, prefix: _data.prefix, rank: _data.rank, firstName: _data.firstName,