add api permissionProfile

This commit is contained in:
AdisakKanthawilang 2025-03-26 16:17:56 +07:00
parent 4e29c6cd71
commit c2b566792d

View file

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