checkpoint
This commit is contained in:
parent
3f3ec27abd
commit
0c7ad61da7
3 changed files with 430 additions and 9 deletions
|
|
@ -741,4 +741,94 @@ export class PermissionController extends Controller {
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Get("checkOrg/{keycloakId}")
|
||||
public async checkOrg(
|
||||
@Path() keycloakId: string,
|
||||
) {
|
||||
console.log("[In Func]");
|
||||
const redisClient = await this.redis.createClient({
|
||||
host: REDIS_HOST,
|
||||
port: REDIS_PORT,
|
||||
});
|
||||
// const getAsync = promisify(redisClient.get).bind(redisClient);
|
||||
|
||||
// let profileType = "OFFICER";
|
||||
let profile: any = await this.profileRepo.findOne({
|
||||
select: ["id"],
|
||||
where: { keycloak: keycloakId },
|
||||
});
|
||||
console.log("[In Func Query Profile]",profile);
|
||||
// if (!profile) {
|
||||
// profileType = "EMPLOYEE";
|
||||
// profile = await this.profileEmployeeRepo.findOne({
|
||||
// select: ["id"],
|
||||
// where: { keycloak: keycloakId },
|
||||
// });
|
||||
// if (!profile) {
|
||||
// throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
// }
|
||||
// }
|
||||
let reply: any;
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
// if (profileType == "OFFICER") {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
current_holderId: profile.id,
|
||||
orgRevisionId: orgRevision?.id,
|
||||
},
|
||||
});
|
||||
if (!posMaster) {
|
||||
reply = {
|
||||
orgRootId: null,
|
||||
orgChild1Id: null,
|
||||
orgChild2Id: null,
|
||||
orgChild3Id: null,
|
||||
orgChild4Id: null,
|
||||
};
|
||||
} else {
|
||||
reply = {
|
||||
orgRootId: posMaster.orgRootId,
|
||||
orgChild1Id: posMaster.orgChild1Id,
|
||||
orgChild2Id: posMaster.orgChild2Id,
|
||||
orgChild3Id: posMaster.orgChild3Id,
|
||||
orgChild4Id: posMaster.orgChild4Id,
|
||||
};
|
||||
}
|
||||
redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply));
|
||||
// } else {
|
||||
// const posMaster = await this.posMasterEmpRepository.findOne({
|
||||
// where: {
|
||||
// current_holderId: profile.id,
|
||||
// orgRevisionId: orgRevision?.id,
|
||||
// },
|
||||
// });
|
||||
// if (!posMaster) {
|
||||
// reply = {
|
||||
// orgRootId: null,
|
||||
// orgChild1Id: null,
|
||||
// orgChild2Id: null,
|
||||
// orgChild3Id: null,
|
||||
// orgChild4Id: null,
|
||||
// };
|
||||
// } else {
|
||||
// reply = {
|
||||
// orgRootId: posMaster.orgRootId,
|
||||
// orgChild1Id: posMaster.orgChild1Id,
|
||||
// orgChild2Id: posMaster.orgChild2Id,
|
||||
// orgChild3Id: posMaster.orgChild3Id,
|
||||
// orgChild4Id: posMaster.orgChild4Id,
|
||||
// };
|
||||
// }
|
||||
// redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply));
|
||||
// }
|
||||
|
||||
return new HttpSuccess(reply);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue