no message
This commit is contained in:
parent
458fb90187
commit
a425fb4848
1 changed files with 80 additions and 62 deletions
|
|
@ -254,6 +254,26 @@ export class PermissionController extends Controller {
|
|||
return new HttpSuccess(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* API permission (dotnet api)
|
||||
* @summary permission (dotnet api)
|
||||
* @param {string} action action
|
||||
* @param {string} system authSysId
|
||||
*/
|
||||
@Get("dotnet-org/{action}/{system}/{profileId}")
|
||||
public async dotnetOrg(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() action: string,
|
||||
@Path() system: string,
|
||||
) {
|
||||
if (!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(action)) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Action ไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
let res = await new permission().PermissionOrg(req, system.toLocaleUpperCase(), action);
|
||||
return new HttpSuccess(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* API permission (dotnet api)
|
||||
* @summary permission (dotnet api)
|
||||
|
|
@ -743,15 +763,13 @@ export class PermissionController extends Controller {
|
|||
}
|
||||
|
||||
@Get("checkOrg/{keycloakId}")
|
||||
public async checkOrg(
|
||||
@Path() keycloakId: string,
|
||||
) {
|
||||
public async checkOrg(@Path() keycloakId: string) {
|
||||
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"],
|
||||
|
|
@ -768,64 +786,64 @@ export class PermissionController extends Controller {
|
|||
// }
|
||||
// }
|
||||
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)); //Create Redis
|
||||
// } 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));
|
||||
// }
|
||||
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)); //Create Redis
|
||||
// } 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