Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
ede21bb2f8
1 changed files with 47 additions and 47 deletions
|
|
@ -35,54 +35,54 @@ export class PermissionController extends Controller {
|
||||||
const getAsync = promisify(redisClient.get).bind(redisClient);
|
const getAsync = promisify(redisClient.get).bind(redisClient);
|
||||||
|
|
||||||
let reply = await getAsync("role_" + request.user.sub);
|
let reply = await getAsync("role_" + request.user.sub);
|
||||||
if (reply != null) {
|
// if (reply != null) {
|
||||||
reply = JSON.parse(reply);
|
// reply = JSON.parse(reply);
|
||||||
} else {
|
// } else {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
select: ["id"],
|
select: ["id"],
|
||||||
where: { keycloak: request.user.sub },
|
where: { keycloak: request.user.sub },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||||
}
|
|
||||||
|
|
||||||
const posMaster = await this.posMasterRepository.findOne({
|
|
||||||
select: ["authRoleId"],
|
|
||||||
where: { current_holderId: profile.id },
|
|
||||||
});
|
|
||||||
if (!posMaster) {
|
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์");
|
|
||||||
}
|
|
||||||
|
|
||||||
const getDetail = await this.authRoleRepo.findOne({
|
|
||||||
select: ["id", "roleName", "roleDescription"],
|
|
||||||
where: { id: posMaster.authRoleId },
|
|
||||||
});
|
|
||||||
if (!getDetail) {
|
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
|
||||||
}
|
|
||||||
|
|
||||||
const roleAttrData = await this.authRoleAttrRepo.find({
|
|
||||||
select: [
|
|
||||||
"authSysId",
|
|
||||||
"parentNode",
|
|
||||||
"attrOwnership",
|
|
||||||
"attrIsCreate",
|
|
||||||
"attrIsList",
|
|
||||||
"attrIsGet",
|
|
||||||
"attrIsUpdate",
|
|
||||||
"attrIsDelete",
|
|
||||||
"attrPrivilege",
|
|
||||||
],
|
|
||||||
where: { authRoleId: getDetail.id },
|
|
||||||
});
|
|
||||||
|
|
||||||
reply = {
|
|
||||||
...getDetail,
|
|
||||||
roles: roleAttrData,
|
|
||||||
};
|
|
||||||
redisClient.setex("role_" + request.user.sub, 86400, JSON.stringify(reply));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
select: ["authRoleId"],
|
||||||
|
where: { current_holderId: profile.id },
|
||||||
|
});
|
||||||
|
if (!posMaster) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์");
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDetail = await this.authRoleRepo.findOne({
|
||||||
|
select: ["id", "roleName", "roleDescription"],
|
||||||
|
where: { id: posMaster.authRoleId },
|
||||||
|
});
|
||||||
|
if (!getDetail) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
|
||||||
|
const roleAttrData = await this.authRoleAttrRepo.find({
|
||||||
|
select: [
|
||||||
|
"authSysId",
|
||||||
|
"parentNode",
|
||||||
|
"attrOwnership",
|
||||||
|
"attrIsCreate",
|
||||||
|
"attrIsList",
|
||||||
|
"attrIsGet",
|
||||||
|
"attrIsUpdate",
|
||||||
|
"attrIsDelete",
|
||||||
|
"attrPrivilege",
|
||||||
|
],
|
||||||
|
where: { authRoleId: getDetail.id },
|
||||||
|
});
|
||||||
|
|
||||||
|
reply = {
|
||||||
|
...getDetail,
|
||||||
|
roles: roleAttrData,
|
||||||
|
};
|
||||||
|
// redisClient.setex("role_" + request.user.sub, 86400, JSON.stringify(reply));
|
||||||
|
// }
|
||||||
return new HttpSuccess(reply);
|
return new HttpSuccess(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue