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
@@ -3,6 +3,7 @@ import { Constants, CrudController } from "@certd/lib-server";
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
import { GroupService } from "../../../modules/basic/service/group-service.js";
import { ApiTags } from "@midwayjs/swagger";
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
/**
* 通知
@@ -20,6 +21,10 @@ export class GroupController extends CrudController<GroupService> {
return this.service;
}
getAuditType(): string {
return AuditType.pipelineGroup;
}
@Post("/page", { description: Constants.per.authOnly, summary: "查询分组分页列表" })
async page(@Body(ALL) body: any) {
const { projectId, userId } = await this.getProjectUserIdRead();
@@ -52,7 +57,9 @@ export class GroupController extends CrudController<GroupService> {
const { projectId, userId } = await this.getProjectUserIdRead();
bean.projectId = projectId;
bean.userId = userId;
return await super.add(bean);
const res = await super.add(bean);
this.auditLog({ content: `新增了分组「${bean.name}」(ID:${res.data})` });
return res;
}
@Post("/update", { description: Constants.per.authOnly, summary: "更新分组" })
@@ -60,7 +67,9 @@ export class GroupController extends CrudController<GroupService> {
await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId;
delete bean.projectId;
return await super.update(bean);
const res = await super.update(bean);
this.auditLog({ content: `修改了分组「${bean.name}」(ID:${bean.id})` });
return res;
}
@Post("/info", { description: Constants.per.authOnly, summary: "查询分组详情" })
async info(@Query("id") id: number) {
@@ -71,7 +80,9 @@ export class GroupController extends CrudController<GroupService> {
@Post("/delete", { description: Constants.per.authOnly, summary: "删除分组" })
async delete(@Query("id") id: number) {
await this.checkOwner(this.getService(), id, "write");
return await super.delete(id);
const res = await super.delete(id);
this.auditLog({ content: `删除了分组(ID:${id})` });
return res;
}
@Post("/all", { description: Constants.per.authOnly, summary: "查询所有分组" })