หา สกจ root

This commit is contained in:
kittapath 2024-11-14 10:31:14 +07:00
parent eab9b79aa7
commit 398c4d6994

View file

@ -922,7 +922,8 @@ export class WorkflowController extends Controller {
},
relations: ["orgChild1"],
});
if (!profileOfficer) return new HttpSuccess({ isOfficer: false, isStaff: false });
if (!profileOfficer)
return new HttpSuccess({ isOfficer: false, isStaff: false, isDirector: false });
let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer;
return new HttpSuccess({
isOfficer: isOfficer,
@ -931,6 +932,40 @@ export class WorkflowController extends Controller {
});
}
/**
* API
*
* @summary
*
*/
@Get("keycloak/isofficer-root/{system}")
async getIsOfficerByKeycloakRoot(@Path() system: string, @Request() req: RequestWithUser) {
const profile = await this.profileRepo.findOne({
where: {
keycloak: req.user.sub,
},
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
const profileOfficer = await this.posMasterRepo.findOne({
where: {
posMasterAssigns: { assignId: system },
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
current_holderId: profile.id,
},
relations: ["orgChild1"],
});
if (!profileOfficer)
return new HttpSuccess({ isOfficer: false, isStaff: false, isDirector: false });
let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer;
return new HttpSuccess({
isOfficer: isOfficer,
isStaff: !isOfficer,
isDirector:
!profileOfficer.orgChild1Id && profileOfficer.orgRootId ? profileOfficer.isDirector : false,
});
}
/**
* API
*