mirror of
https://github.com/certd/certd.git
synced 2026-07-15 02:07:38 +08:00
chore: audit log first
This commit is contained in:
@@ -1,6 +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";
|
||||
|
||||
/**
|
||||
* 权限资源
|
||||
@@ -28,7 +29,13 @@ export class PermissionController extends CrudController<PermissionService> {
|
||||
@Body(ALL)
|
||||
bean
|
||||
) {
|
||||
return await super.add(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" })
|
||||
@@ -36,14 +43,26 @@ export class PermissionController extends CrudController<PermissionService> {
|
||||
@Body(ALL)
|
||||
bean
|
||||
) {
|
||||
return await super.update(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" })
|
||||
async delete(
|
||||
@Query("id")
|
||||
id: number
|
||||
) {
|
||||
return await super.delete(id);
|
||||
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" })
|
||||
|
||||
Reference in New Issue
Block a user