feat: 支持审计日志,操作日志

This commit is contained in:
xiaojunnuo
2026-07-12 02:29:54 +08:00
parent 4250d0e266
commit f2855d6dac
83 changed files with 1252 additions and 1341 deletions
@@ -40,6 +40,8 @@ export class AuthorityMiddleware implements IWebMiddleware {
await next();
return;
}
ctx.auditRouteInfo = routeInfo;
this.extractProjectId(ctx);
let permission = routeInfo.description || "";
permission = permission.trim().split(" ")[0];
if (permission == null || permission === "") {
@@ -109,6 +111,16 @@ export class AuthorityMiddleware implements IWebMiddleware {
return;
}
private extractProjectId(ctx: IMidwayKoaContext) {
const headerVal = ctx.headers["project-id"] as string;
const queryVal = (ctx.request as any)?.query?.projectId;
const bodyVal = (ctx.request as any)?.body?.projectId;
const raw = headerVal || queryVal || bodyVal;
if (raw != null && raw !== "") {
ctx.projectId = parseInt(String(raw), 10) || 0;
}
}
private getTokenFromRequest(ctx: IMidwayKoaContext) {
let token = ctx.get("Authorization") || "";
token = token.replace("Bearer ", "").trim();