add api get profileId
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s

This commit is contained in:
Adisak 2026-01-28 14:17:31 +07:00
parent b64a8bb26d
commit 14c26cce72

View file

@ -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<string, any> },
) {
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
*