From 14c26cce723fc6a81f2ec2ea8584fca8d9195923 Mon Sep 17 00:00:00 2001 From: Adisak Date: Wed, 28 Jan 2026 14:17:31 +0700 Subject: [PATCH] add api get profileId --- .../OrganizationDotnetController.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 5c5f78f1..99b90bc5 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -404,6 +404,42 @@ export class OrganizationDotnetController extends Controller { return new HttpSuccess(orgRoot); } + /** + * API Get ProfileId + * + * @summary Get ProfileId + * + */ + @Get("get-profileId") + async getProfileInbox( + @Request() request: { user: Record }, + ) { + let profile: any + //OFF + profile = await this.profileRepo.findOne({ + where: { keycloak: request.user.sub }, + select: { id: true } + }); + //EMP + if (!profile) { + profile = await this.profileEmpRepo.findOne({ + where: { keycloak: request.user.sub }, + select: { id: true } + }); + if (!profile) { + if (request.user.role.includes("SUPER_ADMIN")) { + return new HttpSuccess(null); + } else { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); + } + } + } + const result = { + profileId: profile ? profile.id : null + } + return new HttpSuccess(result); + } + /** * 3. API Get Profile จาก keycloak id *