mirror of
https://github.com/certd/certd.git
synced 2026-07-13 08:47:34 +08:00
feat: 支持审计日志,操作日志
This commit is contained in:
@@ -5,6 +5,7 @@ import { checkPlus } from "@certd/plus-core";
|
||||
import { http, logger, utils } from "@certd/basic";
|
||||
import { TaskServiceBuilder } from "../../../modules/pipeline/service/getter/task-service-getter.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* Addon
|
||||
@@ -24,6 +25,10 @@ export class AddonController extends CrudController<AddonService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.addon;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询Addon分页列表" })
|
||||
async page(@Body(ALL) body) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -68,7 +73,9 @@ export class AddonController extends CrudController<AddonService> {
|
||||
if (define.needPlus) {
|
||||
checkPlus();
|
||||
}
|
||||
return super.add(bean);
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({ content: `新增了Addon「${bean.name}」(ID:${res.data}, 类型:${bean.type})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新Addon" })
|
||||
@@ -91,7 +98,9 @@ export class AddonController extends CrudController<AddonService> {
|
||||
}
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return super.update(bean);
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({ content: `修改了Addon「${bean.name}」(ID:${bean.id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询Addon详情" })
|
||||
@@ -103,7 +112,9 @@ export class AddonController extends CrudController<AddonService> {
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除Addon" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
return super.delete(id);
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({ content: `删除了Addon(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/define", { description: Constants.per.authOnly, summary: "查询Addon插件定义" })
|
||||
@@ -158,6 +169,7 @@ export class AddonController extends CrudController<AddonService> {
|
||||
async setDefault(@Query("addonType") addonType: string, @Query("id") id: number) {
|
||||
const { projectId, userId } = await this.checkOwner(this.getService(), id, "write", true);
|
||||
const res = await this.service.setDefault(id, userId, addonType, projectId);
|
||||
this.auditLog({ content: `设置了默认Addon(ID:${id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,20 @@ export class AuditLogController extends BaseController {
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "分页查询当前用户操作日志" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const userId = this.getUserId();
|
||||
if (!body.query) {
|
||||
body.query = {};
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
const query: any = { }
|
||||
if (projectId) {
|
||||
//如果是项目级别,排除userId参数,因为日志这里userId不是-1 ,而是实际的用户
|
||||
query.projectId = projectId;
|
||||
}else{
|
||||
query.userId = userId;
|
||||
}
|
||||
body.query.userId = userId;
|
||||
body.query = {
|
||||
...body.query || {},
|
||||
...query,
|
||||
scope: "user"
|
||||
}
|
||||
|
||||
const pageRet = await this.auditService.page(body);
|
||||
return this.ok(pageRet);
|
||||
}
|
||||
|
||||
@@ -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: "查询所有分组" })
|
||||
|
||||
+17
-4
@@ -2,6 +2,7 @@ import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/c
|
||||
import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { CertApplyTemplateService } from "../../../modules/cert/service/cert-apply-template-service.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
@Provide()
|
||||
@Controller("/api/cert/apply-template")
|
||||
@@ -14,6 +15,10 @@ export class CertApplyTemplateController extends CrudController<CertApplyTemplat
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.certTemplate;
|
||||
}
|
||||
|
||||
private removeContent(data: any) {
|
||||
const records = Array.isArray(data) ? data : data?.records;
|
||||
if (!records) {
|
||||
@@ -53,7 +58,9 @@ export class CertApplyTemplateController extends CrudController<CertApplyTemplat
|
||||
const { projectId, userId } = await this.getProjectUserIdWrite();
|
||||
bean.projectId = projectId;
|
||||
bean.userId = userId;
|
||||
return super.add(bean);
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({ content: `新增了证书参数模版(ID:${res.data})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新证书申请参数模版" })
|
||||
@@ -61,7 +68,9 @@ export class CertApplyTemplateController extends CrudController<CertApplyTemplat
|
||||
await this.checkOwner(this.getService(), bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return super.update(bean);
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({ content: `修改了证书参数模版(ID:${bean.id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询证书申请参数模版详情" })
|
||||
@@ -73,13 +82,17 @@ export class CertApplyTemplateController extends CrudController<CertApplyTemplat
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除证书申请参数模版" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
return super.delete(id);
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({ content: `删除了证书参数模版(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/setDefault", { description: Constants.per.authOnly, summary: "设置默认证书申请参数模版" })
|
||||
async setDefault(@Body("id") id: number) {
|
||||
const { projectId, userId } = await this.getProjectUserIdWrite();
|
||||
return this.ok(await this.service.setDefault(id, userId, projectId));
|
||||
const defaultId = await this.service.setDefault(id, userId, projectId);
|
||||
this.auditLog({ content: `设置了默认证书参数模版(ID:${id})` });
|
||||
return this.ok(defaultId);
|
||||
}
|
||||
|
||||
@Post("/default", { description: Constants.per.authOnly, summary: "查询默认证书申请参数模版" })
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/c
|
||||
import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { DnsPersistRecordService } from "../../../modules/cert/service/dns-persist-record-service.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
@Provide()
|
||||
@Controller("/api/cert/dns-persist")
|
||||
@@ -14,6 +15,10 @@ export class DnsPersistRecordController extends CrudController<DnsPersistRecordS
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.dnsPersist;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询DNS持久验证记录分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -28,7 +33,9 @@ export class DnsPersistRecordController extends CrudController<DnsPersistRecordS
|
||||
const { projectId, userId } = await this.getProjectUserIdWrite();
|
||||
bean.projectId = projectId;
|
||||
bean.userId = userId;
|
||||
return super.add(bean);
|
||||
const res = await this.getService().add(bean);
|
||||
this.auditLog({ content: `新增了DNS持久验证记录(ID:${res.id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新DNS持久验证记录" })
|
||||
@@ -36,7 +43,9 @@ export class DnsPersistRecordController extends CrudController<DnsPersistRecordS
|
||||
await this.checkOwner(this.getService(), bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return super.update(bean);
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({ content: `修改了DNS持久验证记录(ID:${bean.id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询DNS持久验证记录详情" })
|
||||
@@ -49,6 +58,7 @@ export class DnsPersistRecordController extends CrudController<DnsPersistRecordS
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
await this.service.delete(id as any);
|
||||
this.auditLog({ content: `删除了DNS持久验证记录(ID:${id})` });
|
||||
return this.ok({
|
||||
message: this.service.lastDeleteMessage,
|
||||
});
|
||||
@@ -80,12 +90,16 @@ export class DnsPersistRecordController extends CrudController<DnsPersistRecordS
|
||||
@Post("/triggerVerify", { description: Constants.per.authOnly, summary: "后台验证DNS持久验证记录" })
|
||||
async triggerVerify(@Body(ALL) body: { id: number }) {
|
||||
await this.checkOwner(this.getService(), body.id, "write");
|
||||
return this.ok(await this.service.triggerVerify(body.id));
|
||||
const res = await this.service.triggerVerify(body.id);
|
||||
this.auditLog({ content: `触发了DNS持久验证(ID:${body.id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post("/createTxt", { description: Constants.per.authOnly, summary: "一键创建DNS持久验证TXT记录" })
|
||||
async createTxt(@Body(ALL) body: { id: number; dnsProviderType?: string; dnsProviderAccess?: number }) {
|
||||
await this.checkOwner(this.getService(), body.id, "write");
|
||||
return this.ok(await this.service.createDnsTxt(body));
|
||||
const res = await this.service.createDnsTxt(body);
|
||||
this.auditLog({ content: `一键创建了DNS持久验证TXT记录(ID:${body.id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { DomainService } from "../../../modules/cert/service/domain-service.js";
|
||||
import { checkPlus } from "@certd/plus-core";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { parseDomainByPsl } from "@certd/plugin-lib";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* 授权
|
||||
@@ -19,6 +20,10 @@ export class DomainController extends CrudController<DomainService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.domain;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询域名分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -58,7 +63,9 @@ export class DomainController extends CrudController<DomainService> {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
bean.projectId = projectId;
|
||||
bean.userId = userId;
|
||||
return super.add(bean);
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({ content: `新增了域名「${bean.domain}」` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新域名" })
|
||||
@@ -66,7 +73,9 @@ export class DomainController extends CrudController<DomainService> {
|
||||
await this.checkOwner(this.getService(), bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return super.update(bean);
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({ content: `修改了域名「${bean.domain}」` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询域名详情" })
|
||||
@@ -78,13 +87,16 @@ export class DomainController extends CrudController<DomainService> {
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除域名" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
return super.delete(id);
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({ content: `删除了域名(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/deleteByIds", { description: Constants.per.authOnly, summary: "批量删除域名" })
|
||||
async deleteByIds(@Body(ALL) body: any) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
await this.service.batchDelete(body.ids, userId, projectId);
|
||||
this.auditLog({ content: `批量删除了${body.ids.length}条域名` });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@@ -99,6 +111,7 @@ export class DomainController extends CrudController<DomainService> {
|
||||
projectId: projectId,
|
||||
};
|
||||
await this.service.startDomainImportTask(req);
|
||||
this.auditLog({ content: "开始了域名导入任务" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@@ -123,6 +136,7 @@ export class DomainController extends CrudController<DomainService> {
|
||||
key,
|
||||
};
|
||||
await this.service.deleteDomainImportTask(req);
|
||||
this.auditLog({ content: "删除了域名导入任务" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@@ -139,6 +153,7 @@ export class DomainController extends CrudController<DomainService> {
|
||||
key,
|
||||
};
|
||||
const item = await this.service.saveDomainImportTask(req);
|
||||
this.auditLog({ content: "保存了域名导入任务" });
|
||||
return this.ok(item);
|
||||
}
|
||||
|
||||
@@ -149,6 +164,7 @@ export class DomainController extends CrudController<DomainService> {
|
||||
userId: userId,
|
||||
projectId: projectId,
|
||||
});
|
||||
this.auditLog({ content: "开始了同步域名过期时间任务" });
|
||||
return this.ok();
|
||||
}
|
||||
@Post("/sync/expiration/status", { description: Constants.per.authOnly, summary: "查询同步域名过期时间任务状态" })
|
||||
@@ -169,6 +185,7 @@ export class DomainController extends CrudController<DomainService> {
|
||||
projectId: projectId,
|
||||
setting: { ...body },
|
||||
});
|
||||
this.auditLog({ content: "保存了域名监控设置" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/c
|
||||
import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { CnameRecordService } from "../../../modules/cname/service/cname-record-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* 授权
|
||||
@@ -17,6 +18,10 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.cname;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询CNAME记录分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const { userId, projectId } = await this.getProjectUserIdRead();
|
||||
@@ -56,7 +61,9 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
|
||||
const { userId, projectId } = await this.getProjectUserIdWrite();
|
||||
bean.userId = userId;
|
||||
bean.projectId = projectId;
|
||||
return super.add(bean);
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({ content: `新增了CNAME记录「${bean.domain}」` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新CNAME记录" })
|
||||
@@ -64,7 +71,9 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
|
||||
await this.checkOwner(this.getService(), bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return super.update(bean);
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({ content: `修改了CNAME记录(ID:${bean.id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询CNAME记录详情" })
|
||||
@@ -76,13 +85,16 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除CNAME记录" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
return super.delete(id);
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({ content: `删除了CNAME记录(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/deleteByIds", { description: Constants.per.authOnly, summary: "批量删除CNAME记录" })
|
||||
async deleteByIds(@Body(ALL) body: any) {
|
||||
const { userId, projectId } = await this.getProjectUserIdWrite();
|
||||
await this.service.batchDelete(body.ids, userId, projectId);
|
||||
this.auditLog({ content: `批量删除了${body.ids.length}条CNAME记录` });
|
||||
return this.ok();
|
||||
}
|
||||
@Post("/getByDomain", { description: Constants.per.authOnly, summary: "根据域名获取CNAME记录" })
|
||||
@@ -103,6 +115,7 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
|
||||
async resetStatus(@Body(ALL) body: { id: number }) {
|
||||
await this.checkOwner(this.getService(), body.id, "read");
|
||||
const res = await this.service.resetStatus(body.id);
|
||||
this.auditLog({ content: `重置了CNAME记录状态(ID:${body.id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
@Post("/import", { description: Constants.per.authOnly, summary: "导入CNAME记录" })
|
||||
@@ -114,6 +127,7 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
|
||||
domainList: body.domainList,
|
||||
cnameProviderId: body.cnameProviderId,
|
||||
});
|
||||
this.auditLog({ append: `提交${res.count}条` });
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AuthService } from "../../../modules/sys/authority/service/auth-service
|
||||
import { ProjectService } from "../../../modules/sys/enterprise/service/project-service.js";
|
||||
import { ProjectMemberService } from "../../../modules/sys/enterprise/service/project-member-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -24,6 +25,10 @@ export class UserProjectController extends BaseController {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.enterprise;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param body
|
||||
* @returns
|
||||
@@ -63,6 +68,7 @@ export class UserProjectController extends BaseController {
|
||||
async applyJoin(@Body(ALL) body: any) {
|
||||
const userId = this.getUserId();
|
||||
const res = await this.service.applyJoin({ userId, projectId: body.projectId });
|
||||
this.auditLog({ content: "申请了加入项目" });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@@ -84,6 +90,7 @@ export class UserProjectController extends BaseController {
|
||||
status,
|
||||
permission,
|
||||
});
|
||||
this.auditLog({ content: "更新了项目成员" });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@@ -92,6 +99,7 @@ export class UserProjectController extends BaseController {
|
||||
const { projectId } = await this.getProjectUserIdAdmin();
|
||||
const { status, permission, userId } = body;
|
||||
const res = await this.service.approveJoin({ userId, projectId: projectId, status, permission });
|
||||
this.auditLog({ content: "审批了加入项目申请" });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@@ -100,8 +108,9 @@ export class UserProjectController extends BaseController {
|
||||
const { projectId } = await this.getProjectUserIdAdmin();
|
||||
await this.projectMemberService.deleteWhere({
|
||||
projectId,
|
||||
userId: this.getUserId(),
|
||||
userId: body.userId,
|
||||
});
|
||||
this.auditLog({ content: "删除了项目成员" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@@ -113,6 +122,7 @@ export class UserProjectController extends BaseController {
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
this.auditLog({ content: "离开了项目" });
|
||||
return this.ok();
|
||||
}
|
||||
}
|
||||
|
||||
+13
-3
@@ -5,6 +5,7 @@ import { ProjectMemberService } from "../../../modules/sys/enterprise/service/pr
|
||||
import { merge } from "lodash-es";
|
||||
import { ProjectService } from "../../../modules/sys/enterprise/service/project-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
/**
|
||||
*/
|
||||
@Provide()
|
||||
@@ -24,6 +25,10 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.enterprise;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询项目成员分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const { projectId } = await this.getProjectUserIdRead();
|
||||
@@ -53,7 +58,9 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
|
||||
projectId: bean.projectId,
|
||||
});
|
||||
|
||||
return super.add(bean);
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({ content: `新增了项目成员(ID:${res.data})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新项目成员" })
|
||||
@@ -71,7 +78,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
|
||||
permission: bean.permission,
|
||||
status: bean.status,
|
||||
});
|
||||
|
||||
this.auditLog({ content: `修改了项目成员(ID:${bean.id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@@ -98,7 +105,9 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
|
||||
userId: this.getUserId(),
|
||||
projectId: projectId,
|
||||
});
|
||||
return super.delete(id);
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({ content: `删除了项目成员(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/deleteByIds", { description: Constants.per.authOnly, summary: "批量删除项目成员" })
|
||||
@@ -115,6 +124,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
|
||||
await this.service.delete(id as any);
|
||||
}
|
||||
|
||||
this.auditLog({ content: `批量删除了${ids.length}条项目成员` });
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { BaseController, Constants } from "@certd/lib-server";
|
||||
import { Controller, Inject, Post, Provide } from "@midwayjs/core";
|
||||
import { TransferService } from "../../../modules/sys/enterprise/service/transfer-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -16,6 +17,10 @@ export class TransferController extends BaseController {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.enterprise;
|
||||
}
|
||||
|
||||
/**
|
||||
* 我自己的资源
|
||||
* @param body
|
||||
@@ -38,6 +43,7 @@ export class TransferController extends BaseController {
|
||||
const { projectId } = await this.getProjectUserIdRead();
|
||||
const userId = this.getUserId();
|
||||
await this.service.transferAll(userId, projectId);
|
||||
this.auditLog({ content: "迁移了项目资源" });
|
||||
return this.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { BaseController } from "@certd/lib-server";
|
||||
import { Constants } from "@certd/lib-server";
|
||||
import { EmailService } from "../../../modules/basic/service/email-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -13,10 +14,15 @@ export class EmailController extends BaseController {
|
||||
@Inject()
|
||||
emailService: EmailService;
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.mine;
|
||||
}
|
||||
|
||||
@Post("/test", { description: Constants.per.authOnly, summary: "测试邮件发送" })
|
||||
public async test(@Body("receiver") receiver) {
|
||||
const userId = super.getUserId();
|
||||
await this.emailService.test(userId, receiver);
|
||||
this.auditLog({ content: "测试了邮件发送" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -31,6 +37,7 @@ export class EmailController extends BaseController {
|
||||
public async add(@Body("email") email) {
|
||||
const userId = super.getUserId();
|
||||
await this.emailService.add(userId, email);
|
||||
this.auditLog({ content: "添加了邮件" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -38,6 +45,7 @@ export class EmailController extends BaseController {
|
||||
public async delete(@Body("email") email) {
|
||||
const userId = super.getUserId();
|
||||
await this.emailService.delete(userId, email);
|
||||
this.auditLog({ content: "删除了邮件" });
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { http, logger, utils } from "@certd/basic";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { CodeService } from "../../../modules/basic/service/code-service.js";
|
||||
import { EmailService } from "../../../modules/basic/service/email-service.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -40,6 +41,10 @@ export class MineController extends BaseController {
|
||||
@Inject()
|
||||
emailService: EmailService;
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.mine;
|
||||
}
|
||||
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询用户信息" })
|
||||
public async info() {
|
||||
const userId = this.getUserId();
|
||||
@@ -73,6 +78,7 @@ export class MineController extends BaseController {
|
||||
public async changePassword(@Body(ALL) body: any) {
|
||||
const userId = this.getUserId();
|
||||
await this.userService.changePassword(userId, body);
|
||||
this.auditLog({ content: "修改了密码" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -80,6 +86,7 @@ export class MineController extends BaseController {
|
||||
public async initPassword(@Body(ALL) body: any) {
|
||||
const userId = this.getUserId();
|
||||
await this.userService.initPassword(userId, body);
|
||||
this.auditLog({ content: "初始化了密码" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -91,6 +98,7 @@ export class MineController extends BaseController {
|
||||
avatar: body.avatar,
|
||||
nickName: body.nickName,
|
||||
});
|
||||
this.auditLog({ content: "更新了个人资料" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -129,6 +137,7 @@ export class MineController extends BaseController {
|
||||
phoneCode: body.phoneCode,
|
||||
mobile: body.mobile,
|
||||
});
|
||||
this.auditLog({ content: "修改了手机号" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -145,6 +154,7 @@ export class MineController extends BaseController {
|
||||
await this.userService.updateEmail(userId, {
|
||||
email: body.email,
|
||||
});
|
||||
this.auditLog({ content: "修改了邮箱" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -198,6 +208,7 @@ export class MineController extends BaseController {
|
||||
}),
|
||||
});
|
||||
|
||||
this.auditLog({ content: "初始化了Let's Encrypt ACME账号和邮件通知" });
|
||||
return this.ok({ success: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { PasskeyService } from "../../../modules/login/service/passkey-service.j
|
||||
import { BaseController, Constants } from "@certd/lib-server";
|
||||
import { UserService } from "../../../modules/sys/authority/service/user-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
@Provide()
|
||||
@Controller("/api/mine/passkey")
|
||||
@@ -14,6 +15,10 @@ export class MinePasskeyController extends BaseController {
|
||||
@Inject()
|
||||
userService: UserService;
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.mine;
|
||||
}
|
||||
|
||||
@Post("/generateRegistration", { description: Constants.per.authOnly, summary: "生成Passkey注册选项" })
|
||||
public async generateRegistration(
|
||||
@Body(ALL)
|
||||
@@ -46,7 +51,7 @@ export class MinePasskeyController extends BaseController {
|
||||
const deviceName = body.deviceName;
|
||||
|
||||
const result = await this.passkeyService.registerPasskey(userId, response, challenge, deviceName, this.ctx);
|
||||
|
||||
this.auditLog({ content: "验证注册了Passkey" });
|
||||
return this.ok(result);
|
||||
}
|
||||
|
||||
@@ -62,6 +67,7 @@ export class MinePasskeyController extends BaseController {
|
||||
|
||||
const result = await this.passkeyService.registerPasskey(userId, response, challenge, deviceName, this.ctx);
|
||||
|
||||
this.auditLog({ content: "注册了Passkey" });
|
||||
return this.ok(result);
|
||||
}
|
||||
|
||||
@@ -90,6 +96,7 @@ export class MinePasskeyController extends BaseController {
|
||||
}
|
||||
|
||||
await this.passkeyService.delete([passkey.id]);
|
||||
this.auditLog({ content: "解绑了Passkey" });
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { merge } from "lodash-es";
|
||||
import { TwoFactorService } from "../../../modules/mine/service/two-factor-service.js";
|
||||
import { isPlus } from "@certd/plus-core";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -19,6 +20,10 @@ export class UserTwoFactorSettingController extends BaseController {
|
||||
@Inject()
|
||||
twoFactorService: TwoFactorService;
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.mine;
|
||||
}
|
||||
|
||||
@Post("/get", { description: Constants.per.authOnly, summary: "获取双因子认证设置" })
|
||||
async get() {
|
||||
const userId = this.getUserId();
|
||||
@@ -42,6 +47,7 @@ export class UserTwoFactorSettingController extends BaseController {
|
||||
}
|
||||
|
||||
await this.service.saveSetting(userId, null, setting);
|
||||
this.auditLog({ content: "保存了双因子认证设置" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -62,6 +68,7 @@ export class UserTwoFactorSettingController extends BaseController {
|
||||
userId,
|
||||
verifyCode: bean.verifyCode,
|
||||
});
|
||||
this.auditLog({ content: "保存了验证器设置" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@@ -69,6 +76,7 @@ export class UserTwoFactorSettingController extends BaseController {
|
||||
async authenticatorOff() {
|
||||
const userId = this.getUserId();
|
||||
await this.twoFactorService.offAuthenticator(userId);
|
||||
this.auditLog({ content: "关闭了验证器" });
|
||||
return this.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { UserGrantSetting } from "../../../modules/mine/service/models.js";
|
||||
import { isPlus } from "@certd/plus-core";
|
||||
import { merge } from "lodash-es";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -20,6 +21,10 @@ export class UserSettingsController extends CrudController<UserSettingsService>
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.mine;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询用户设置分页列表" })
|
||||
async page(@Body(ALL) body) {
|
||||
body.query = body.query ?? {};
|
||||
@@ -62,6 +67,7 @@ export class UserSettingsController extends CrudController<UserSettingsService>
|
||||
async save(@Body(ALL) bean: UserSettingsEntity) {
|
||||
bean.userId = this.getUserId();
|
||||
await this.service.save(bean);
|
||||
this.auditLog({ content: "保存了用户设置" });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -88,6 +94,7 @@ export class UserSettingsController extends CrudController<UserSettingsService>
|
||||
merge(setting, bean);
|
||||
|
||||
await this.service.saveSetting(userId, null, setting);
|
||||
this.auditLog({ content: "保存了授权设置" });
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { logger } from "@certd/basic";
|
||||
import dayjs from "dayjs";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { CertReader } from "@certd/plugin-lib";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -29,6 +30,10 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.monitor;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询证书分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
body.query = body.query ?? {};
|
||||
@@ -117,7 +122,9 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
||||
const { projectId, userId } = await this.getProjectUserIdWrite();
|
||||
bean.projectId = projectId;
|
||||
bean.userId = userId;
|
||||
return await super.add(bean);
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({ content: `新增了证书(ID:${res.data})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新证书" })
|
||||
@@ -125,7 +132,9 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
||||
await this.checkOwner(this.service, bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return await super.update(bean);
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({ content: `修改了证书(ID:${bean.id})` });
|
||||
return res;
|
||||
}
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询证书详情" })
|
||||
async info(@Query("id") id: number) {
|
||||
@@ -136,7 +145,9 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除证书" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.service, 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: "查询所有证书" })
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ApiTags } from "@midwayjs/swagger";
|
||||
import { SiteInfoService } from "../../../modules/monitor/index.js";
|
||||
import { JobHistoryService } from "../../../modules/monitor/service/job-history-service.js";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -22,6 +23,10 @@ export class JobHistoryController extends CrudController<JobHistoryService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.jobHistory;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询监控运行历史分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -54,12 +59,15 @@ export class JobHistoryController extends CrudController<JobHistoryService> {
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除监控运行历史" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.service, id, "write");
|
||||
return await super.delete(id);
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({ content: `删除了监控运行历史(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
@Post("/batchDelete", { description: Constants.per.authOnly, summary: "批量删除监控运行历史" })
|
||||
async batchDelete(@Body("ids") ids: number[]) {
|
||||
const { projectId, userId } = await this.getProjectUserIdWrite();
|
||||
await this.service.batchDelete(ids, userId, projectId);
|
||||
this.auditLog({ content: `批量删除了${ids.length}条监控运行历史` });
|
||||
return this.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { merge } from "lodash-es";
|
||||
import { SiteIpService } from "../../../modules/monitor/service/site-ip-service.js";
|
||||
import { utils } from "@certd/basic";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType, AuditAction } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -25,6 +25,10 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.monitor;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询站点监控分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
body.query = body.query ?? {};
|
||||
@@ -76,8 +80,6 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
this.service.check(entity.id, true, 0);
|
||||
}
|
||||
this.auditLog({
|
||||
type: AuditType.monitor,
|
||||
action: AuditAction.add,
|
||||
content: `新增了站点监控「${bean.name}」(ID:${res.id}, 域名:${bean.domain})`,
|
||||
});
|
||||
return this.ok(res);
|
||||
@@ -94,8 +96,6 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
this.service.check(entity.id, true, 0);
|
||||
}
|
||||
this.auditLog({
|
||||
type: AuditType.monitor,
|
||||
action: AuditAction.update,
|
||||
content: `修改了站点监控「${bean.name}」(ID:${bean.id})`,
|
||||
});
|
||||
return this.ok();
|
||||
@@ -111,8 +111,6 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
await this.checkOwner(this.service, id, "write");
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({
|
||||
type: AuditType.monitor,
|
||||
action: AuditAction.delete,
|
||||
content: `删除了站点监控(ID:${id})`,
|
||||
});
|
||||
return res;
|
||||
@@ -121,11 +119,9 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
@Post("/batchDelete", { description: Constants.per.authOnly, summary: "批量删除站点监控" })
|
||||
async batchDelete(@Body(ALL) body: any) {
|
||||
const { projectId, userId } = await this.getProjectUserIdWrite();
|
||||
await this.service.batchDelete(body.ids, userId, projectId);
|
||||
const count = await this.service.batchDelete(body.ids, userId, projectId);
|
||||
this.auditLog({
|
||||
type: AuditType.monitor,
|
||||
action: AuditAction.batchDelete,
|
||||
content: `批量删除了${body.ids.length}条站点监控`,
|
||||
content: `批量删除了${count}条站点监控`,
|
||||
});
|
||||
return this.ok();
|
||||
}
|
||||
@@ -154,6 +150,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
userId,
|
||||
projectId,
|
||||
});
|
||||
this.auditLog({ content: "导入了站点监控" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@@ -191,6 +188,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
projectId: projectId,
|
||||
key,
|
||||
});
|
||||
this.auditLog({ content: "删除了站点监控导入任务" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@@ -203,6 +201,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
userId: userId,
|
||||
projectId: projectId,
|
||||
});
|
||||
this.auditLog({ content: "开始了站点监控导入任务" });
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AuthService } from "../../../modules/sys/authority/service/auth-service
|
||||
import { SiteIpService } from "../../../modules/monitor/service/site-ip-service.js";
|
||||
import { SiteInfoService } from "../../../modules/monitor/index.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -22,6 +23,10 @@ export class SiteInfoController extends CrudController<SiteIpService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.siteIp;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询站点IP分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -57,6 +62,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
|
||||
const { domain, httpsPort } = siteEntity;
|
||||
this.service.check(res.id, domain, httpsPort);
|
||||
}
|
||||
this.auditLog({ content: `新增了站点IP(ID:${res.id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@@ -71,6 +77,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
|
||||
const { domain, httpsPort } = siteEntity;
|
||||
this.service.check(siteEntity.id, domain, httpsPort);
|
||||
}
|
||||
this.auditLog({ content: `修改了站点IP(ID:${bean.id})` });
|
||||
return this.ok();
|
||||
}
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询站点IP详情" })
|
||||
@@ -85,6 +92,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
|
||||
const entity = await this.service.info(id);
|
||||
const res = await super.delete(id);
|
||||
await this.service.updateIpCount(entity.siteId);
|
||||
this.auditLog({ content: `删除了站点IP(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -124,6 +132,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
|
||||
siteId: body.siteId,
|
||||
projectId,
|
||||
});
|
||||
this.auditLog({ content: "导入了站点IP" });
|
||||
return this.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { OpenKeyService } from "../../../modules/open/service/open-key-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType, AuditAction } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -19,6 +19,10 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.openKey;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询开放API密钥分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -58,8 +62,6 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
|
||||
body.userId = userId;
|
||||
const res = await this.service.add(body);
|
||||
this.auditLog({
|
||||
type: AuditType.openKey,
|
||||
action: AuditAction.add,
|
||||
content: `新增了API密钥(ID:${res.id}, scope:${body.scope})`,
|
||||
});
|
||||
return this.ok(res);
|
||||
@@ -72,8 +74,6 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
|
||||
delete bean.projectId;
|
||||
await this.service.update(bean);
|
||||
this.auditLog({
|
||||
type: AuditType.openKey,
|
||||
action: AuditAction.update,
|
||||
content: `修改了API密钥(ID:${bean.id})`,
|
||||
});
|
||||
return this.ok();
|
||||
@@ -102,8 +102,6 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({
|
||||
type: AuditType.openKey,
|
||||
action: AuditAction.delete,
|
||||
content: `删除了API密钥(ID:${id})`,
|
||||
});
|
||||
return res;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { AccessService } from "@certd/lib-server";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { AccessDefine } from "@certd/pipeline";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType, AuditAction } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* 授权
|
||||
@@ -21,6 +21,10 @@ export class AccessController extends CrudController<AccessService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.access;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询授权配置分页列表" })
|
||||
async page(@Body(ALL) body) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -60,8 +64,6 @@ export class AccessController extends CrudController<AccessService> {
|
||||
bean.projectId = projectId;
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({
|
||||
type: AuditType.access,
|
||||
action: AuditAction.add,
|
||||
content: `新增了授权「${bean.name}」(ID:${res.data}, 类型:${bean.type})`,
|
||||
});
|
||||
return res;
|
||||
@@ -74,8 +76,6 @@ export class AccessController extends CrudController<AccessService> {
|
||||
delete bean.projectId;
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({
|
||||
type: AuditType.access,
|
||||
action: AuditAction.update,
|
||||
content: `修改了授权「${bean.name}」(ID:${bean.id})`,
|
||||
});
|
||||
return res;
|
||||
@@ -91,8 +91,6 @@ export class AccessController extends CrudController<AccessService> {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({
|
||||
type: AuditType.access,
|
||||
action: AuditAction.delete,
|
||||
content: `删除了授权(ID:${id})`,
|
||||
});
|
||||
return res;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { AuthService } from "../../../modules/sys/authority/service/auth-service
|
||||
import { NotificationDefine } from "@certd/pipeline";
|
||||
import { checkPlus } from "@certd/plus-core";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType, AuditAction } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* 通知
|
||||
@@ -22,6 +22,10 @@ export class NotificationController extends CrudController<NotificationService>
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.notification;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询通知配置分页列表" })
|
||||
async page(@Body(ALL) body) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -64,8 +68,6 @@ export class NotificationController extends CrudController<NotificationService>
|
||||
}
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({
|
||||
type: AuditType.notification,
|
||||
action: AuditAction.add,
|
||||
content: `新增了通知配置「${bean.name}」(ID:${res.data}, 类型:${bean.type})`,
|
||||
});
|
||||
return res;
|
||||
@@ -92,8 +94,6 @@ export class NotificationController extends CrudController<NotificationService>
|
||||
delete bean.projectId;
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({
|
||||
type: AuditType.notification,
|
||||
action: AuditAction.update,
|
||||
content: `修改了通知配置「${bean.name}」(ID:${bean.id})`,
|
||||
});
|
||||
return res;
|
||||
@@ -109,8 +109,6 @@ export class NotificationController extends CrudController<NotificationService>
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({
|
||||
type: AuditType.notification,
|
||||
action: AuditAction.delete,
|
||||
content: `删除了通知配置(ID:${id})`,
|
||||
});
|
||||
return res;
|
||||
@@ -172,6 +170,7 @@ export class NotificationController extends CrudController<NotificationService>
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
const res = await this.service.setDefault(id, userId, projectId);
|
||||
this.auditLog({ content: `设置了默认通知配置(ID:${id})` });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { HistoryService } from "../../../modules/pipeline/service/history-servic
|
||||
import { PipelineService } from "../../../modules/pipeline/service/pipeline-service.js";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { PipelineEntity } from "../../../modules/pipeline/entity/pipeline.js";
|
||||
import { AuditType, AuditAction } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
const pipelineExample = `
|
||||
// 流水线配置示例,实际传送时要去掉注释
|
||||
@@ -124,11 +124,14 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
@Inject()
|
||||
siteInfoService: SiteInfoService;
|
||||
|
||||
|
||||
getService() {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.pipeline;
|
||||
}
|
||||
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询流水线分页列表" })
|
||||
async page(@Body(ALL) body) {
|
||||
const isAdmin = await this.authService.isAdmin(this.ctx);
|
||||
@@ -216,8 +219,6 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
|
||||
const title = bean.title;
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: isNew ? AuditAction.add : AuditAction.update,
|
||||
content: isNew ? `创建了流水线「${title}」(ID:${bean.id})` : `修改了流水线「${title}」(ID:${bean.id})`,
|
||||
projectId,
|
||||
});
|
||||
@@ -240,8 +241,6 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
await this.checkOwner(this.getService(), id, "write", true);
|
||||
await this.service.delete(id);
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.delete,
|
||||
content: `删除了流水线(ID:${id})`,
|
||||
});
|
||||
return this.ok({});
|
||||
@@ -253,6 +252,7 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
await this.service.disabled(bean.id, bean.disabled);
|
||||
this.auditLog({ content: `${bean.disabled ? "禁用" : "启用"}了流水线(ID:${bean.id})` });
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@@ -268,8 +268,6 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
await this.checkOwner(this.getService(), id, "write", true);
|
||||
await this.service.trigger(id, stepId, true);
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.execute,
|
||||
content: `手动执行了流水线(ID:${id})`,
|
||||
});
|
||||
return this.ok({});
|
||||
@@ -280,8 +278,6 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
await this.checkOwner(this.historyService, historyId, "write", true);
|
||||
await this.service.cancel(historyId);
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.cancel,
|
||||
content: `取消了流水线执行(historyId:${historyId})`,
|
||||
});
|
||||
return this.ok({});
|
||||
@@ -307,91 +303,77 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
|
||||
@Post("/batchDelete", { description: Constants.per.authOnly, summary: "批量删除流水线" })
|
||||
async batchDelete(@Body("ids") ids: number[]) {
|
||||
await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
await this.service.batchDelete(ids, userId, projectId);
|
||||
const count = await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
return await this.service.batchDelete(ids, userId, projectId);
|
||||
});
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.batchDelete,
|
||||
content: `批量删除了${ids.length}条流水线`,
|
||||
content: `批量删除了${count}条流水线`,
|
||||
});
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post("/batchUpdateGroup", { description: Constants.per.authOnly, summary: "批量更新流水线分组" })
|
||||
async batchUpdateGroup(@Body("ids") ids: number[], @Body("groupId") groupId: number) {
|
||||
await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
await this.service.batchUpdateGroup(ids, groupId, userId, projectId);
|
||||
const count = await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
return await this.service.batchUpdateGroup(ids, groupId, userId, projectId);
|
||||
});
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.batchUpdate,
|
||||
content: `批量修改了${ids.length}条流水线分组`,
|
||||
content: `批量修改了${count}条流水线分组`,
|
||||
});
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post("/batchUpdateTrigger", { description: Constants.per.authOnly, summary: "批量更新流水线触发器" })
|
||||
async batchUpdateTrigger(@Body("ids") ids: number[], @Body("trigger") trigger: any) {
|
||||
await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
await this.service.batchUpdateTrigger(ids, trigger, userId, projectId);
|
||||
const count = await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
return await this.service.batchUpdateTrigger(ids, trigger, userId, projectId);
|
||||
});
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.batchUpdate,
|
||||
content: `批量修改了${ids.length}条流水线触发器`,
|
||||
content: `批量修改了${count}条流水线触发器`,
|
||||
});
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post("/batchUpdateNotification", { description: Constants.per.authOnly, summary: "批量更新流水线通知" })
|
||||
async batchUpdateNotification(@Body("ids") ids: number[], @Body("notification") notification: any) {
|
||||
await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
await this.service.batchUpdateNotifications(ids, notification, userId, projectId);
|
||||
const count = await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
return await this.service.batchUpdateNotifications(ids, notification, userId, projectId);
|
||||
});
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.batchUpdate,
|
||||
content: `批量修改了${ids.length}条流水线通知`,
|
||||
content: `批量修改了${count}条流水线通知`,
|
||||
});
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post("/batchUpdateCertApplyOptions", { description: Constants.per.authOnly, summary: "批量更新证书申请任务配置" })
|
||||
async batchUpdateCertApplyOptions(@Body("ids") ids: number[], @Body("options") options: any) {
|
||||
await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
await this.service.batchUpdateCertApplyOptions(ids, options, userId, projectId);
|
||||
const count = await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
return await this.service.batchUpdateCertApplyOptions(ids, options, userId, projectId);
|
||||
});
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.batchUpdate,
|
||||
content: `批量修改了${ids.length}条流水线证书申请配置`,
|
||||
content: `批量修改了${count}条流水线证书申请配置`,
|
||||
});
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post("/batchRerun", { description: Constants.per.authOnly, summary: "批量重新运行流水线" })
|
||||
async batchRerun(@Body("ids") ids: number[], @Body("force") force: boolean) {
|
||||
await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
await this.service.batchRerun(ids, force, userId, projectId);
|
||||
const count = await this.checkPermissionCall(async ({ userId, projectId }) => {
|
||||
return await this.service.batchRerun(ids, force, userId, projectId);
|
||||
});
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.execute,
|
||||
content: `批量重新执行了${ids.length}条流水线`,
|
||||
content: `批量重新执行了${count}条流水线`,
|
||||
});
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post("/batchTransfer", { description: Constants.per.authOnly, summary: "批量迁移流水线" })
|
||||
async batchTransfer(@Body("ids") ids: number[], @Body("toProjectId") toProjectId: number) {
|
||||
await this.checkPermissionCall(async ({}) => {
|
||||
await this.service.batchTransfer(ids, toProjectId);
|
||||
const count = await this.checkPermissionCall(async ({}) => {
|
||||
return await this.service.batchTransfer(ids, toProjectId);
|
||||
});
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.batchUpdate,
|
||||
content: `批量迁移了${ids.length}条流水线`,
|
||||
content: `批量迁移了${count}条流水线`,
|
||||
});
|
||||
return this.ok({});
|
||||
}
|
||||
@@ -401,8 +383,6 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
await this.checkOwner(this.getService(), id, "write", true);
|
||||
const res = await this.service.refreshWebhookKey(id);
|
||||
this.auditLog({
|
||||
type: AuditType.pipeline,
|
||||
action: AuditAction.update,
|
||||
content: `刷新了流水线(ID:${id})的Webhook密钥`,
|
||||
});
|
||||
return this.ok({
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { PipelineGroupService } from "../../../modules/pipeline/service/pipeline-group-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* 通知
|
||||
@@ -20,6 +21,10 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
|
||||
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 PipelineGroupController extends CrudController<PipelineGroupService
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
bean.userId = userId;
|
||||
bean.projectId = projectId;
|
||||
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 PipelineGroupController extends CrudController<PipelineGroupService
|
||||
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 PipelineGroupController extends CrudController<PipelineGroupService
|
||||
@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: "查询所有流水线分组" })
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/c
|
||||
import { SubDomainService } from "../../../modules/pipeline/service/sub-domain-service.js";
|
||||
import { TaskServiceBuilder } from "../../../modules/pipeline/service/getter/task-service-getter.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
|
||||
|
||||
/**
|
||||
* 子域名托管
|
||||
@@ -22,6 +23,10 @@ export class SubDomainController extends CrudController<SubDomainService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
getAuditType(): string {
|
||||
return AuditType.subDomain;
|
||||
}
|
||||
|
||||
@Post("/parseDomain", { description: Constants.per.authOnly, summary: "解析域名" })
|
||||
async parseDomain(@Body("fullDomain") fullDomain: string) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
@@ -64,7 +69,9 @@ export class SubDomainController extends CrudController<SubDomainService> {
|
||||
const { userId, projectId } = await this.getProjectUserIdRead();
|
||||
bean.userId = userId;
|
||||
bean.projectId = projectId;
|
||||
return super.add(bean);
|
||||
const res = await super.add(bean);
|
||||
this.auditLog({ content: `新增了子域名(ID:${res.data})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新子域名" })
|
||||
@@ -72,7 +79,9 @@ export class SubDomainController extends CrudController<SubDomainService> {
|
||||
await this.checkOwner(this.getService(), bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return super.update(bean);
|
||||
const res = await super.update(bean);
|
||||
this.auditLog({ content: `修改了子域名(ID:${bean.id})` });
|
||||
return res;
|
||||
}
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询子域名详情" })
|
||||
async info(@Query("id") id: number) {
|
||||
@@ -83,7 +92,9 @@ export class SubDomainController extends CrudController<SubDomainService> {
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除子域名" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
return super.delete(id);
|
||||
const res = await super.delete(id);
|
||||
this.auditLog({ content: `删除了子域名(ID:${id})` });
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post("/batchDelete", { description: Constants.per.authOnly, summary: "批量删除子域名" })
|
||||
|
||||
@@ -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