mirror of
https://github.com/certd/certd.git
synced 2026-07-29 08:37:36 +08:00
feat: 支持审计日志,操作日志
This commit is contained in:
@@ -3,6 +3,7 @@ import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { TemplateService } from "../../../modules/pipeline/service/template-service.js";
|
||||
import { checkPlus } from "@certd/plus-core";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* 流水线模版
|
||||
@@ -18,6 +19,10 @@ export class TemplateController extends CrudController<TemplateService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.template;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询流水线模版分页列表" })
|
||||
async page(@Body(ALL) body) {
|
||||
body.query = body.query ?? {};
|
||||
@@ -52,7 +57,9 @@ export class TemplateController extends CrudController<TemplateService> {
|
||||
bean.userId = userId;
|
||||
bean.projectId = projectId;
|
||||
checkPlus();
|
||||
return 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 TemplateController extends CrudController<TemplateService> {
|
||||
await this.checkOwner(this.service, bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return 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) {
|
||||
@@ -72,6 +81,7 @@ export class TemplateController extends CrudController<TemplateService> {
|
||||
async delete(@Query("id") id: number) {
|
||||
const { userId, projectId } = await this.getProjectUserIdWrite();
|
||||
await this.service.batchDelete([id], userId, projectId);
|
||||
this.auditLog({ content: `删除了流水线模版(ID:${id})` });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -79,6 +89,7 @@ export class TemplateController extends CrudController<TemplateService> {
|
||||
async batchDelete(@Body("ids") ids: number[]) {
|
||||
const { userId, projectId } = await this.getProjectUserIdWrite();
|
||||
await this.service.batchDelete(ids, userId, projectId);
|
||||
this.auditLog({ content: `批量删除了${ids.length}条流水线模版` });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -95,6 +106,7 @@ export class TemplateController extends CrudController<TemplateService> {
|
||||
body.projectId = projectId;
|
||||
checkPlus();
|
||||
const res = await this.service.createPipelineByTemplate(body);
|
||||
this.auditLog({ content: `根据模版创建了流水线(ID:${res.id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user