no message
This commit is contained in:
parent
d897c8c041
commit
fa52b33786
4 changed files with 1007 additions and 13 deletions
|
|
@ -4,7 +4,6 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { AuthRole } from "../entities/AuthRole";
|
||||
import { AuthRoleAttr } from "../entities/AuthRoleAttr";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
|
|
@ -197,16 +196,60 @@ export class PermissionController extends Controller {
|
|||
*/
|
||||
@Get("dotnet/{action}/{system}")
|
||||
public async dotnet(
|
||||
@Request() req: RequestWithUser,
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() action: string,
|
||||
@Path() system: string
|
||||
@Path() system: string,
|
||||
) {
|
||||
|
||||
if(!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(action)) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Action ไม่ถูกต้อง");
|
||||
if (!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(action)) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Action ไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
let res = await new permission().Permission(req, system.toLocaleUpperCase(), action);
|
||||
return new HttpSuccess(res);
|
||||
}
|
||||
|
||||
@Get("org")
|
||||
public async listAuthSysOrg(@Request() request: RequestWithUser) {
|
||||
const redisClient = await this.redis.createClient({
|
||||
host: REDIS_HOST,
|
||||
port: REDIS_PORT,
|
||||
});
|
||||
const getAsync = promisify(redisClient.get).bind(redisClient);
|
||||
|
||||
const profile = await this.profileRepo.findOne({
|
||||
// select: ["id"],
|
||||
where: { keycloak: request.user.sub },
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
|
||||
let reply = await getAsync("posMaster_" + profile.id);
|
||||
if (reply != null) {
|
||||
reply = JSON.parse(reply);
|
||||
} else {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
current_holderId: profile.id,
|
||||
orgRevision: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!posMaster) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งในโครงสร้าง");
|
||||
}
|
||||
reply = {
|
||||
orgRootId: posMaster.orgRootId,
|
||||
orgChild1Id: posMaster.orgChild1Id,
|
||||
orgChild2Id: posMaster.orgChild2Id,
|
||||
orgChild3Id: posMaster.orgChild3Id,
|
||||
orgChild4Id: posMaster.orgChild4Id,
|
||||
};
|
||||
redisClient.setex("posMaster_" + profile.id, 86400, JSON.stringify(reply));
|
||||
}
|
||||
|
||||
return new HttpSuccess(reply);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue