From c2b566792dc3d5e06be7fc11731501606c3b1f67 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 26 Mar 2025 16:17:56 +0700 Subject: [PATCH] add api permissionProfile --- src/controllers/ProfileController.ts | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 7db0ee09..c3d85d14 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -6167,6 +6167,50 @@ export class ProfileController extends Controller { return new HttpSuccess(mapData); } + /** + * API ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ + * + * @summary ORG_065 - ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ + * + */ + @Get("keycloak/permissionProfile") + async getPermissionProfile( + @Request() request: { user: Record } + ) { + let orgRevisionPublish: any = await this.orgRevisionRepo + .createQueryBuilder("orgRevision") + .where("orgRevision.orgRevisionIsDraft = false") + .andWhere("orgRevision.orgRevisionIsCurrent = true") + .getOne(); + if (!orgRevisionPublish) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง"); + } + const profile = await this.profileRepo.findOne({ + where: {keycloak: request.user.sub }, + }); + if(!profile){ + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้"); + } + const permissionProflile = await this.permissionProflileRepository.findOne({ + relations : ["orgRootTree"], + where:{ + profileId: profile.id, + orgRootTree:{ + orgRevisionId: orgRevisionPublish.id + } + } + }); + + const _profile: any = { + profileId: profile?.id??null, + isEdit: permissionProflile?.isEdit??false, + isCheck: permissionProflile?.isCheck??false, + }; + + + return new HttpSuccess(_profile); + } + /** * API ข้อมูลทะเบียนประวัติตาม keycloak *