From 398c4d6994d2c74e3c23c8369343123a2ce20ea2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 14 Nov 2024 10:31:14 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AB=E0=B8=B2=20=E0=B8=AA=E0=B8=81?= =?UTF-8?q?=E0=B8=88=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/WorkflowController.ts | 37 ++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 236fdcac..cf7cbd36 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -922,7 +922,8 @@ export class WorkflowController extends Controller { }, relations: ["orgChild1"], }); - if (!profileOfficer) return new HttpSuccess({ isOfficer: false, isStaff: false }); + if (!profileOfficer) + return new HttpSuccess({ isOfficer: false, isStaff: false, isDirector: false }); let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; return new HttpSuccess({ isOfficer: isOfficer, @@ -931,6 +932,40 @@ export class WorkflowController extends Controller { }); } + /** + * API เช็ค สกจ + * + * @summary เช็ค สกจ + * + */ + @Get("keycloak/isofficer-root/{system}") + async getIsOfficerByKeycloakRoot(@Path() system: string, @Request() req: RequestWithUser) { + const profile = await this.profileRepo.findOne({ + where: { + keycloak: req.user.sub, + }, + }); + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน"); + + const profileOfficer = await this.posMasterRepo.findOne({ + where: { + posMasterAssigns: { assignId: system }, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + current_holderId: profile.id, + }, + relations: ["orgChild1"], + }); + if (!profileOfficer) + return new HttpSuccess({ isOfficer: false, isStaff: false, isDirector: false }); + let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; + return new HttpSuccess({ + isOfficer: isOfficer, + isStaff: !isOfficer, + isDirector: + !profileOfficer.orgChild1Id && profileOfficer.orgRootId ? profileOfficer.isDirector : false, + }); + } + /** * API เช็ค สกจ *