add api get profileId
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
This commit is contained in:
parent
b64a8bb26d
commit
14c26cce72
1 changed files with 36 additions and 0 deletions
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue