no message

This commit is contained in:
kittapath 2024-11-05 22:05:12 +07:00
parent 458fb90187
commit a425fb4848

View file

@ -254,6 +254,26 @@ export class PermissionController extends Controller {
return new HttpSuccess(res); 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) * API permission (dotnet api)
* @summary permission (dotnet api) * @summary permission (dotnet api)
@ -743,15 +763,13 @@ export class PermissionController extends Controller {
} }
@Get("checkOrg/{keycloakId}") @Get("checkOrg/{keycloakId}")
public async checkOrg( public async checkOrg(@Path() keycloakId: string) {
@Path() keycloakId: string,
) {
const redisClient = await this.redis.createClient({ const redisClient = await this.redis.createClient({
host: REDIS_HOST, host: REDIS_HOST,
port: REDIS_PORT, port: REDIS_PORT,
}); });
// const getAsync = promisify(redisClient.get).bind(redisClient); // const getAsync = promisify(redisClient.get).bind(redisClient);
// let profileType = "OFFICER"; // let profileType = "OFFICER";
let profile: any = await this.profileRepo.findOne({ let profile: any = await this.profileRepo.findOne({
select: ["id"], select: ["id"],
@ -768,64 +786,64 @@ export class PermissionController extends Controller {
// } // }
// } // }
let reply: any; let reply: any;
const orgRevision = await this.orgRevisionRepository.findOne({ const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"], select: ["id"],
where: { where: {
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
}, },
}); });
// if (profileType == "OFFICER") { // if (profileType == "OFFICER") {
const posMaster = await this.posMasterRepository.findOne({ const posMaster = await this.posMasterRepository.findOne({
where: { where: {
current_holderId: profile.id, current_holderId: profile.id,
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
}, },
}); });
if (!posMaster) { if (!posMaster) {
reply = { reply = {
orgRootId: null, orgRootId: null,
orgChild1Id: null, orgChild1Id: null,
orgChild2Id: null, orgChild2Id: null,
orgChild3Id: null, orgChild3Id: null,
orgChild4Id: null, orgChild4Id: null,
}; };
} else { } else {
reply = { reply = {
orgRootId: posMaster.orgRootId, orgRootId: posMaster.orgRootId,
orgChild1Id: posMaster.orgChild1Id, orgChild1Id: posMaster.orgChild1Id,
orgChild2Id: posMaster.orgChild2Id, orgChild2Id: posMaster.orgChild2Id,
orgChild3Id: posMaster.orgChild3Id, orgChild3Id: posMaster.orgChild3Id,
orgChild4Id: posMaster.orgChild4Id, orgChild4Id: posMaster.orgChild4Id,
}; };
} }
redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply)); //Create Redis redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply)); //Create Redis
// } else { // } else {
// const posMaster = await this.posMasterEmpRepository.findOne({ // const posMaster = await this.posMasterEmpRepository.findOne({
// where: { // where: {
// current_holderId: profile.id, // current_holderId: profile.id,
// orgRevisionId: orgRevision?.id, // orgRevisionId: orgRevision?.id,
// }, // },
// }); // });
// if (!posMaster) { // if (!posMaster) {
// reply = { // reply = {
// orgRootId: null, // orgRootId: null,
// orgChild1Id: null, // orgChild1Id: null,
// orgChild2Id: null, // orgChild2Id: null,
// orgChild3Id: null, // orgChild3Id: null,
// orgChild4Id: null, // orgChild4Id: null,
// }; // };
// } else { // } else {
// reply = { // reply = {
// orgRootId: posMaster.orgRootId, // orgRootId: posMaster.orgRootId,
// orgChild1Id: posMaster.orgChild1Id, // orgChild1Id: posMaster.orgChild1Id,
// orgChild2Id: posMaster.orgChild2Id, // orgChild2Id: posMaster.orgChild2Id,
// orgChild3Id: posMaster.orgChild3Id, // orgChild3Id: posMaster.orgChild3Id,
// orgChild4Id: posMaster.orgChild4Id, // orgChild4Id: posMaster.orgChild4Id,
// }; // };
// } // }
// redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply)); // redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply));
// } // }
return new HttpSuccess(reply); return new HttpSuccess(reply);
} }