From 87ee9b5b12c2d1dc4f8fe9448ca1d9204e14b6bd Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Fri, 21 Mar 2025 15:03:55 +0700 Subject: [PATCH 1/2] workflow add keycloakId --- src/controllers/WorkflowController.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 1e305874..ccdf3bfe 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -378,6 +378,7 @@ export class WorkflowController extends Controller { can_delete: false, can_cancel: false, can_sign: false, + keycloakId: workflow.createdUserId, }); } return new HttpSuccess({ @@ -392,6 +393,7 @@ export class WorkflowController extends Controller { can_delete: operator.canDelete, can_cancel: operator.canCancel, can_sign: operator.canSign, + keycloakId: workflow.createdUserId, }); } @@ -800,15 +802,15 @@ export class WorkflowController extends Controller { keyword: string; page: number; pageSize: number; - profileId?: string | null; + keycloakId?: string | null; }, ) { let posMasterUser: PosMaster = new PosMaster(); - if (body.profileId) { + if (body.keycloakId) { posMasterUser = (await this.posMasterRepo.findOne({ where: { orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, - current_holderId: body.profileId, + current_holder: { keycloak: body.keycloakId }, }, relations: ["current_holder", "current_holder.posType", "current_holder.posLevel"], })) as PosMaster; From 1f0ae6cc5adf28f1092fafa0a4c3e12d0533d099 Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Fri, 21 Mar 2025 16:36:11 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/WorkflowController.ts | 65 ++++++++++++++++++--------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index ccdf3bfe..a8dac61d 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -827,38 +827,63 @@ export class WorkflowController extends Controller { if (!posMasterUser || !posMasterUser.orgRootId) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน"); - let condition: any = { - isDirector: true, - orgRootId: posMasterUser.orgRootId, - orgRevisionId: posMasterUser.orgRevisionId, - }; + let condition: any = []; let conditionOfficer: any = { isDirector: true, isOfficer: true, orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: IsNull(), }; if (type.trim().toUpperCase() == "OPERATE") { - condition = { + condition.push({ isDirector: true, orgRootId: posMasterUser.orgRootId, orgRevisionId: posMasterUser.orgRevisionId, - // orgChild1Id: IsNull(), - // orgChild2Id: IsNull(), - // orgChild3Id: IsNull(), - // orgChild4Id: IsNull(), - }; - if (posMasterUser.orgChild4Id == null) { - condition.orgChild4Id = IsNull(); - } else if (posMasterUser.orgChild3Id == null) { - condition.orgChild3Id = IsNull(); - } else if (posMasterUser.orgChild2Id == null) { - condition.orgChild2Id = IsNull(); - } else if (posMasterUser.orgChild1Id == null) { - condition.orgChild1Id = IsNull(); - } + orgChild1Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: posMasterUser.orgChild3Id, + orgChild4Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: posMasterUser.orgChild3Id, + orgChild4Id: posMasterUser.orgChild4Id, + }); } else { + condition = [ + { + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + }, + ]; if ( (posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" && posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญงาน") ||