From 6cfb6607424ebdc8e006091bb792f152cf1202f6 Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 21 Oct 2024 14:28:11 +0700 Subject: [PATCH] no message --- src/controllers/WorkflowController.ts | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 06c70ae6..a69906d0 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -700,4 +700,35 @@ export class WorkflowController extends Controller { let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer }); } + + /** + * API เช็ค สกจ + * + * @summary เช็ค สกจ + * + */ + @Post("keycloak/isofficer/{system}") + async checkPermissionWorkflow( + @Request() req: RequestWithUser, + @Body() + body: { + refId: string; + }, + ) { + const profile = await this.profileRepo.findOne({ + where: { + keycloak: req.user.sub, + }, + }); + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน"); + + const profileOfficer = await this.workflowRepo.findOne({ + where: { + states: { stateUserComments: { profile: { keycloak: req.user.sub } } }, + refId: body.refId, + }, + }); + if (!profileOfficer) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์"); + return new HttpSuccess(); + } }