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
@@ -1,7 +1,7 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
import { CrudController } from "@certd/lib-server";
import { PermissionService } from "../../../modules/sys/authority/service/permission-service.js";
import { AuditType, AuditAction } from "../../modules/sys/enterprise/service/audit-constants.js";
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
/**
* 权限资源
@@ -15,8 +15,11 @@ export class PermissionController extends CrudController<PermissionService> {
getService() {
return this.service;
}
getAuditType(): string {
return AuditType.permission;
}
@Post("/page", { description: "sys:auth:per:view" })
@Post("/page", { description: "sys:auth:per:view", summary: "查询权限分页列表" })
async page(
@Body(ALL)
body
@@ -24,48 +27,42 @@ export class PermissionController extends CrudController<PermissionService> {
return await super.page(body);
}
@Post("/add", { description: "sys:auth:per:add" })
@Post("/add", { description: "sys:auth:per:add", summary: "添加权限" })
async add(
@Body(ALL)
bean
) {
const res = await super.add(bean);
await this.auditLog({
type: AuditType.permission,
action: AuditAction.add,
content: `新增了权限「${bean.name}」(ID:${res.data})`,
});
return res;
}
@Post("/update", { description: "sys:auth:per:edit" })
@Post("/update", { description: "sys:auth:per:edit", summary: "更新权限" })
async update(
@Body(ALL)
bean
) {
const res = await super.update(bean);
await this.auditLog({
type: AuditType.permission,
action: AuditAction.update,
content: `修改了权限「${bean.name}」(ID:${bean.id})`,
});
return res;
}
@Post("/delete", { description: "sys:auth:per:remove" })
@Post("/delete", { description: "sys:auth:per:remove", summary: "删除权限" })
async delete(
@Query("id")
id: number
) {
const res = await super.delete(id);
await this.auditLog({
type: AuditType.permission,
action: AuditAction.delete,
content: `删除了权限(ID:${id})`,
});
return res;
}
@Post("/tree", { description: "sys:auth:per:view" })
@Post("/tree", { description: "sys:auth:per:view", summary: "查询权限树" })
async tree() {
const tree = await this.service.tree({});
return this.ok(tree);