chore: 增加流水线,授权等文档

This commit is contained in:
xiaojunnuo
2026-03-15 18:26:49 +08:00
parent 25e361b9f9
commit 1cbf9c1cd9
42 changed files with 497 additions and 241 deletions
@@ -21,7 +21,7 @@ export class AccessController extends CrudController<AccessService> {
return this.service;
}
@Post('/page', { description: Constants.per.authOnly })
@Post('/page', { description: Constants.per.authOnly, summary: "查询授权配置分页列表" })
async page(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead()
body.query = body.query ?? {};
@@ -44,7 +44,7 @@ export class AccessController extends CrudController<AccessService> {
return this.ok(res);
}
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询授权配置列表" })
async list(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead()
body.query = body.query ?? {};
@@ -53,7 +53,7 @@ export class AccessController extends CrudController<AccessService> {
return super.list(body);
}
@Post('/add', { description: Constants.per.authOnly })
@Post('/add', { description: Constants.per.authOnly, summary: "添加授权配置" })
async add(@Body(ALL) bean) {
const { projectId, userId } = await this.getProjectUserIdWrite()
bean.userId = userId;
@@ -61,39 +61,39 @@ export class AccessController extends CrudController<AccessService> {
return super.add(bean);
}
@Post('/update', { description: Constants.per.authOnly })
@Post('/update', { description: Constants.per.authOnly, summary: "更新授权配置" })
async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId;
delete bean.projectId;
return super.update(bean);
}
@Post('/info', { description: Constants.per.authOnly })
@Post('/info', { description: Constants.per.authOnly, summary: "查询授权配置详情" })
async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read");
return super.info(id);
}
@Post('/delete', { description: Constants.per.authOnly })
@Post('/delete', { description: Constants.per.authOnly, summary: "删除授权配置" })
async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write");
return super.delete(id);
}
@Post('/define', { description: Constants.per.authOnly })
@Post('/define', { description: Constants.per.authOnly, summary: "查询授权插件定义" })
async define(@Query('type') type: string) {
const access = this.service.getDefineByType(type);
return this.ok(access);
}
@Post('/getSecretPlain', { description: Constants.per.authOnly })
@Post('/getSecretPlain', { description: Constants.per.authOnly, summary: "获取授权配置明文密钥" })
async getSecretPlain(@Body(ALL) body: { id: number; key: string }) {
const {userId, projectId} = await this.checkOwner(this.getService(), body.id, "read");
const value = await this.service.getById(body.id, userId, projectId);
return this.ok(value[body.key]);
}
@Post('/accessTypeDict', { description: Constants.per.authOnly })
@Post('/accessTypeDict', { description: Constants.per.authOnly, summary: "查询授权类型字典" })
async getAccessTypeDict() {
let list: AccessDefine[] = this.service.getDefineList();
list = list.sort((a,b) => {
@@ -110,7 +110,7 @@ export class AccessController extends CrudController<AccessService> {
return this.ok(dict);
}
@Post('/simpleInfo', { description: Constants.per.authOnly })
@Post('/simpleInfo', { description: Constants.per.authOnly, summary: "查询授权配置简单信息" })
async simpleInfo(@Query('id') id: number) {
// await this.authService.checkUserIdButAllowAdmin(this.ctx, this.service, id);
// await this.checkOwner(this.getService(), id, "read",true);
@@ -118,7 +118,7 @@ export class AccessController extends CrudController<AccessService> {
return this.ok(res);
}
@Post('/getDictByIds', { description: Constants.per.authOnly })
@Post('/getDictByIds', { description: Constants.per.authOnly, summary: "根据ID列表获取授权配置字典" })
async getDictByIds(@Body('ids') ids: number[]) {
const { userId, projectId } = await this.getProjectUserIdRead()
const res = await this.service.getSimpleByIds(ids, userId, projectId);
@@ -21,7 +21,7 @@ export class CertController extends BaseController {
userSettingsService: UserSettingsService;
@Post('/get', { description: Constants.per.authOnly })
@Post('/get', { description: Constants.per.authOnly, summary: "获取证书" })
async getCert(@Query('id') id: number) {
const {userId} = await this.getProjectUserIdRead()
@@ -46,7 +46,7 @@ export class CertController extends BaseController {
}
@Post('/readCertDetail', { description: Constants.per.authOnly })
@Post('/readCertDetail', { description: Constants.per.authOnly, summary: "读取证书详情" })
async readCertDetail(@Body('crt') crt: string) {
if (!crt) {
throw new Error('crt is required');
@@ -14,13 +14,13 @@ export class DnsProviderController extends BaseController {
@Inject()
service: DnsProviderService;
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询DNS提供商列表" })
async list(@Query(ALL) query: any) {
const list = this.service.getList();
return this.ok(list);
}
@Post('/dnsProviderTypeDict', { description: Constants.per.authOnly })
@Post('/dnsProviderTypeDict', { description: Constants.per.authOnly, summary: "查询DNS提供商类型字典" })
async getDnsProviderTypeDict() {
const list = this.service.getList();
const dict = [];
@@ -34,7 +34,7 @@ export class HandleController extends BaseController {
@Inject()
notificationService: NotificationService;
@Post('/access', { description: Constants.per.authOnly })
@Post('/access', { description: Constants.per.authOnly, summary: "处理授权请求" })
async accessRequest(@Body(ALL) body: AccessRequestHandleReq) {
const {projectId,userId} = await this.getProjectUserIdRead()
let inputAccess = body.input;
@@ -64,7 +64,7 @@ export class HandleController extends BaseController {
return this.ok(res);
}
@Post('/notification', { description: Constants.per.authOnly })
@Post('/notification', { description: Constants.per.authOnly, summary: "处理通知请求" })
async notificationRequest(@Body(ALL) body: NotificationRequestHandleReq) {
const input = body.input;
@@ -80,7 +80,7 @@ export class HandleController extends BaseController {
return this.ok(res);
}
@Post('/plugin', { description: Constants.per.authOnly })
@Post('/plugin', { description: Constants.per.authOnly, summary: "处理插件请求" })
async pluginRequest(@Body(ALL) body: PluginRequestHandleReq) {
const {projectId,userId} = await this.getProjectUserIdRead()
const pluginDefine = pluginRegistry.get(body.typeName);
@@ -41,7 +41,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.service;
}
@Post('/page', { description: Constants.per.authOnly })
@Post('/page', { description: Constants.per.authOnly, summary: "查询流水线执行历史分页列表" })
async page(@Body(ALL) body: any) {
const { projectId, userId } = await this.getProjectUserIdRead()
body.query.projectId = projectId
@@ -88,7 +88,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(res);
}
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询流水线执行历史列表" })
async list(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead()
if (!body){
@@ -151,7 +151,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(listRet);
}
@Post('/add', { description: Constants.per.authOnly })
@Post('/add', { description: Constants.per.authOnly, summary: "添加流水线执行历史" })
async add(@Body(ALL) bean: PipelineEntity) {
const { projectId, userId } = await this.getProjectUserIdRead()
bean.projectId = projectId
@@ -159,7 +159,7 @@ export class HistoryController extends CrudController<HistoryService> {
return super.add(bean);
}
@Post('/update', { description: Constants.per.authOnly })
@Post('/update', { description: Constants.per.authOnly, summary: "更新流水线执行历史" })
async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id,"write",true);
delete bean.userId;
@@ -167,7 +167,7 @@ export class HistoryController extends CrudController<HistoryService> {
return super.update(bean);
}
@Post('/save', { description: Constants.per.authOnly })
@Post('/save', { description: Constants.per.authOnly, summary: "保存流水线执行历史" })
async save(@Body(ALL) bean: HistoryEntity) {
const { projectId,userId } = await this.getProjectUserIdWrite()
bean.userId = userId;
@@ -183,7 +183,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(bean.id);
}
@Post('/saveLog', { description: Constants.per.authOnly })
@Post('/saveLog', { description: Constants.per.authOnly, summary: "保存流水线执行日志" })
async saveLog(@Body(ALL) bean: HistoryLogEntity) {
const { projectId,userId } = await this.getProjectUserIdWrite()
bean.projectId = projectId;
@@ -198,14 +198,14 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(bean.id);
}
@Post('/delete', { description: Constants.per.authOnly })
@Post('/delete', { description: Constants.per.authOnly, summary: "删除流水线执行历史" })
async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"write",true);
await super.delete(id);
return this.ok();
}
@Post('/deleteByIds', { description: Constants.per.authOnly })
@Post('/deleteByIds', { description: Constants.per.authOnly, summary: "批量删除流水线执行历史" })
async deleteByIds(@Body(ALL) body: any) {
let {userId} = await this.checkOwner(this.getService(), body.ids,"write",true);
const isAdmin = await this.authService.isAdmin(this.ctx);
@@ -214,21 +214,21 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok();
}
@Post('/detail', { description: Constants.per.authOnly })
@Post('/detail', { description: Constants.per.authOnly, summary: "查询流水线执行历史详情" })
async detail(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"read",true);
const detail = await this.service.detail(id);
return this.ok(detail);
}
@Post('/logs', { description: Constants.per.authOnly })
@Post('/logs', { description: Constants.per.authOnly, summary: "查询流水线执行日志" })
async logs(@Query('id') id: number) {
await this.checkOwner(this.logService, id,"read",true);
const logInfo = await this.logService.info(id);
return this.ok(logInfo);
}
@Post('/files', { description: Constants.per.authOnly })
@Post('/files', { description: Constants.per.authOnly, summary: "查询流水线执行文件" })
async files(@Query('pipelineId') pipelineId: number, @Query('historyId') historyId: number) {
const files = await this.getFiles(historyId, pipelineId);
return this.ok(files);
@@ -269,7 +269,7 @@ export class HistoryController extends CrudController<HistoryService> {
return await this.service.getFiles(history);
}
@Get('/download', { description: Constants.per.authOnly })
@Get('/download', { description: Constants.per.authOnly, summary: "下载流水线执行文件" })
async download(@Query('pipelineId') pipelineId: number, @Query('historyId') historyId: number, @Query('fileId') fileId: string) {
const files = await this.getFiles(historyId, pipelineId);
const file = files.find(f => f.id === fileId);
@@ -22,7 +22,7 @@ export class NotificationController extends CrudController<NotificationService>
return this.service;
}
@Post('/page', { description: Constants.per.authOnly })
@Post('/page', { description: Constants.per.authOnly, summary: "查询通知配置分页列表" })
async page(@Body(ALL) body) {
const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {};
@@ -40,7 +40,7 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(res);
}
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询通知配置列表" })
async list(@Body(ALL) body) {
const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {};
@@ -49,7 +49,7 @@ export class NotificationController extends CrudController<NotificationService>
return super.list(body);
}
@Post('/add', { description: Constants.per.authOnly })
@Post('/add', { description: Constants.per.authOnly, summary: "添加通知配置" })
async add(@Body(ALL) bean) {
const {projectId,userId} = await this.getProjectUserIdRead();
bean.userId = userId;
@@ -65,7 +65,7 @@ export class NotificationController extends CrudController<NotificationService>
return super.add(bean);
}
@Post('/update', { description: Constants.per.authOnly })
@Post('/update', { description: Constants.per.authOnly, summary: "更新通知配置" })
async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id,"write");
const old = await this.service.info(bean.id);
@@ -86,25 +86,25 @@ export class NotificationController extends CrudController<NotificationService>
delete bean.projectId;
return super.update(bean);
}
@Post('/info', { description: Constants.per.authOnly })
@Post('/info', { description: Constants.per.authOnly, summary: "查询通知配置详情" })
async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"read");
return super.info(id);
}
@Post('/delete', { description: Constants.per.authOnly })
@Post('/delete', { description: Constants.per.authOnly, summary: "删除通知配置" })
async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"write");
return super.delete(id);
}
@Post('/define', { description: Constants.per.authOnly })
@Post('/define', { description: Constants.per.authOnly, summary: "查询通知插件定义" })
async define(@Query('type') type: string) {
const notification = this.service.getDefineByType(type);
return this.ok(notification);
}
@Post('/getTypeDict', { description: Constants.per.authOnly })
@Post('/getTypeDict', { description: Constants.per.authOnly, summary: "查询通知类型字典" })
async getTypeDict() {
const list: any = this.service.getDefineList();
let dict = [];
@@ -125,7 +125,7 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(dict);
}
@Post('/simpleInfo', { description: Constants.per.authOnly })
@Post('/simpleInfo', { description: Constants.per.authOnly, summary: "查询通知配置简单信息" })
async simpleInfo(@Query('id') id: number) {
const {projectId,userId} = await this.getProjectUserIdRead();
if (id === 0) {
@@ -142,14 +142,14 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(res);
}
@Post('/getDefaultId', { description: Constants.per.authOnly })
@Post('/getDefaultId', { description: Constants.per.authOnly, summary: "查询默认通知配置ID" })
async getDefaultId() {
const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.getDefault(userId,projectId);
return this.ok(res?.id);
}
@Post('/setDefault', { description: Constants.per.authOnly })
@Post('/setDefault', { description: Constants.per.authOnly, summary: "设置默认通知配置" })
async setDefault(@Query('id') id: number) {
const {projectId,userId} = await this.getProjectUserIdRead();
await this.checkOwner(this.getService(), id,"write");
@@ -157,14 +157,14 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(res);
}
@Post('/getOrCreateDefault', { description: Constants.per.authOnly })
@Post('/getOrCreateDefault', { description: Constants.per.authOnly, summary: "获取或创建默认通知配置" })
async getOrCreateDefault(@Body('email') email: string) {
const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.getOrCreateDefault(email, userId,projectId);
return this.ok(res);
}
@Post('/options', { description: Constants.per.authOnly })
@Post('/options', { description: Constants.per.authOnly, summary: "查询通知配置选项" })
async options() {
const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.list({
@@ -1,12 +1,108 @@
import { Constants, CrudController, SysSettingsService } from '@certd/lib-server';
import { isPlus } from '@certd/plus-core';
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
import { ApiProperty, ApiTags } from '@midwayjs/swagger';
import { SiteInfoService } from '../../../modules/monitor/index.js';
import { PipelineEntity } from '../../../modules/pipeline/entity/pipeline.js';
import { HistoryService } from '../../../modules/pipeline/service/history-service.js';
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
import { ApiTags } from '@midwayjs/swagger';
const pipelineExample = `
// 流水线配置示例,实际传送时要去掉注释
{
"title": "handsfree.work证书自动化", //标题
"runnableType": "pipeline", //类型,固定为pipeline
"projectId": 1, // 项目ID 未开启企业模式,无需传递
"type": "cert", // 流水线类型,cert:证书自动化, custom :自定义流水线
"from": "", // 来源,cert:证书自动化, upload :证书托管
"stages": [ //流水线阶段,多个阶段串行执行
{
"id": "edKopnpp2wvOCQ2vkV8Ii" // 阶段ID, 由客户端生成,流水线内部全局唯一即可
"title": "证书申请阶段", //阶段标题
"runnableType": "stage", // 类型标识
"tasks": [ // 任务列表,多个任务并行执行
{
"id": "Lb8I7Dj10cGh6gqIIkmKv" // 任务ID, 由客户端生成,流水线内部全局唯一即可
"title": "证书申请任务", // 任务标题
"runnableType": "task", // 类型标识
"steps": [ // 步骤列表,同一个任务下的多个步骤串行执行
{
"id": "zc8X1L2f0N0KgbrqFU3gz" // 步骤ID, 由客户端生成,流水线内部全局唯一即可
"type": "CertApply", // 插件类型
"title": "申请证书", // 步骤标题
"runnableType": "step", // 类型标识
"input": { //输入参数 ,根据插件的配置有不同的参数,具体参数建议通过浏览器F12进行查看
"renewDays": 15,
},
"strategy": { // 策略
"runStrategy": 0 // 运行策略,0:正常执行,1:成功后跳过
},
}
],
}
],
}
],
"triggers": [ // 触发器配置
{
"id": "pt3865qfIAkULBS5sOQf7", // 触发器ID, 由客户端生成,流水线内部全局唯一即可
"title": "定时触发",
"type": "timer", // 触发器类型,timer:定时触发
"props": {
"cron": "0 34 5 * * *" // 定时表达式
},
}
],
"notifications": [ // 通知配置
{
"id": "5pb1gZTnDEjdHkR5tDd6g" // 通知ID, 由客户端生成,流水线内部全局唯一即可
"title": "使用默认通知",// 通知标题
"type": "custom", // 通知类型,固定为custom
"when": [ // 触发条件,error:错误时触发,turnToSuccess:失败转成功后触发,success: 成功时触发
"error",
"turnToSuccess"
],
"notificationId": 0, // 通知ID 0为使用默认通知
}
],
}`
export class PipelineSaveDTO {
@ApiProperty({ description: 'Id,修改时必传' })
id: number;
userId: number;
@ApiProperty({ description: '标题' })
title: string;
@ApiProperty({ description: '流水线详细配置,json格式的字符串', example: pipelineExample })
content: string;
@ApiProperty({ description: '保留历史版本数量' })
keepHistoryCount: number;
@ApiProperty({ description: '分组ID' })
groupId: number;
@ApiProperty({ description: '备注' })
remark: string;
@ApiProperty({ description: '状态' })
status: string;
@ApiProperty({ description: '是否禁用' })
disabled: boolean;
@ApiProperty({ description: '类型' })
type: string;
webhookKey: string;
@ApiProperty({ description: '来源' })
from: string;
@ApiProperty({ description: '排序' })
order: number;
@ApiProperty({ description: '项目ID' })
projectId: number;
@ApiProperty({ description: '流水线有效期,单位秒' })
validTime: number;
@ApiProperty({ description: '是否增加证书监控' })
addToMonitorEnabled: boolean
@ApiProperty({ description: '增加证书监控的域名,逗号分隔' })
addToMonitorDomains: string
}
/**
* 证书
@@ -32,7 +128,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.service;
}
@Post('/page', { description: Constants.per.authOnly })
@Post('/page', { description: Constants.per.authOnly, summary: "查询流水线分页列表" })
async page(@Body(ALL) body) {
const isAdmin = await this.authService.isAdmin(this.ctx);
const publicSettings = await this.sysSettingsService.getPublicSettings();
@@ -79,7 +175,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok(pageRet);
}
@Post('/getSimpleByIds', { description: Constants.per.authOnly })
@Post('/getSimpleByIds', { description: Constants.per.authOnly, summary: "根据ID列表获取流水线简单信息" })
async getSimpleById(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead()
const ret = await this.getService().getSimplePipelines(body.ids, userId, projectId);
@@ -104,7 +200,7 @@ export class PipelineController extends CrudController<PipelineService> {
// }
@Post('/save', { description: Constants.per.authOnly, summary: '新增/更新流水线' })
async save(@Body(ALL) bean: { addToMonitorEnabled: boolean, addToMonitorDomains: string } & PipelineEntity) {
async save(@Body() bean: PipelineSaveDTO) {
const { userId ,projectId} = await this.getProjectUserIdWrite()
if (bean.id > 0) {
const {userId,projectId} = await this.checkOwner(this.getService(), bean.id,"write",true);
@@ -120,7 +216,7 @@ export class PipelineController extends CrudController<PipelineService> {
delete bean.validTime
}
const { version } = await this.service.save(bean);
const { version } = await this.service.save(bean as any);
//是否增加证书监控
if (bean.addToMonitorEnabled && bean.addToMonitorDomains) {
const sysPublicSettings = await this.sysSettingsService.getPublicSettings();
@@ -136,14 +232,14 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({ id: bean.id, version: version });
}
@Post('/delete', { description: Constants.per.authOnly })
@Post('/delete', { description: Constants.per.authOnly, summary: "删除流水线" })
async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"write",true);
await this.service.delete(id);
return this.ok({});
}
@Post('/disabled', { description: Constants.per.authOnly })
@Post('/disabled', { description: Constants.per.authOnly, summary: "禁用流水线" })
async disabled(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id,"write",true);
delete bean.userId;
@@ -152,28 +248,28 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({});
}
@Post('/detail', { description: Constants.per.authOnly })
@Post('/detail', { description: Constants.per.authOnly, summary: "查询流水线详情" })
async detail(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"read",true);
const detail = await this.service.detail(id);
return this.ok(detail);
}
@Post('/trigger', { description: Constants.per.authOnly })
@Post('/trigger', { description: Constants.per.authOnly, summary: "触发流水线执行" })
async trigger(@Query('id') id: number, @Query('stepId') stepId?: string) {
await this.checkOwner(this.getService(), id,"write",true);
await this.service.trigger(id, stepId, true);
return this.ok({});
}
@Post('/cancel', { description: Constants.per.authOnly })
@Post('/cancel', { description: Constants.per.authOnly, summary: "取消流水线执行" })
async cancel(@Query('historyId') historyId: number) {
await this.checkOwner(this.historyService, historyId,"write",true);
await this.service.cancel(historyId);
return this.ok({});
}
@Post('/count', { description: Constants.per.authOnly })
@Post('/count', { description: Constants.per.authOnly, summary: "查询流水线数量" })
async count() {
const { userId } = await this.getProjectUserIdRead()
const count = await this.service.count({ userId: userId });
@@ -191,7 +287,7 @@ export class PipelineController extends CrudController<PipelineService> {
return await callback({userId});
}
@Post('/batchDelete', { description: Constants.per.authOnly })
@Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除流水线" })
async batchDelete(@Body('ids') ids: number[]) {
// let { projectId ,userId} = await this.getProjectUserIdWrite()
// if(projectId){
@@ -210,7 +306,7 @@ export class PipelineController extends CrudController<PipelineService> {
@Post('/batchUpdateGroup', { description: Constants.per.authOnly })
@Post('/batchUpdateGroup', { description: Constants.per.authOnly, summary: "批量更新流水线分组" })
async batchUpdateGroup(@Body('ids') ids: number[], @Body('groupId') groupId: number) {
// let { projectId ,userId} = await this.getProjectUserIdWrite()
// if(projectId){
@@ -228,7 +324,7 @@ export class PipelineController extends CrudController<PipelineService> {
}
@Post('/batchUpdateTrigger', { description: Constants.per.authOnly })
@Post('/batchUpdateTrigger', { description: Constants.per.authOnly, summary: "批量更新流水线触发器" })
async batchUpdateTrigger(@Body('ids') ids: number[], @Body('trigger') trigger: any) {
// let { projectId ,userId} = await this.getProjectUserIdWrite()
// if(projectId){
@@ -245,7 +341,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({});
}
@Post('/batchUpdateNotification', { description: Constants.per.authOnly })
@Post('/batchUpdateNotification', { description: Constants.per.authOnly, summary: "批量更新流水线通知" })
async batchUpdateNotification(@Body('ids') ids: number[], @Body('notification') notification: any) {
// const isAdmin = await this.authService.isAdmin(this.ctx);
// const userId = isAdmin ? undefined : this.getUserId();
@@ -256,7 +352,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({});
}
@Post('/batchRerun', { description: Constants.per.authOnly })
@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);
@@ -264,7 +360,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({});
}
@Post('/batchTransfer', { description: Constants.per.authOnly })
@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);
@@ -272,7 +368,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({});
}
@Post('/refreshWebhookKey', { description: Constants.per.authOnly })
@Post('/refreshWebhookKey', { description: Constants.per.authOnly, summary: "刷新Webhook密钥" })
async refreshWebhookKey(@Body('id') id: number) {
await this.checkOwner(this.getService(), id,"write",true);
const res = await this.service.refreshWebhookKey(id);
@@ -20,7 +20,7 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return this.service;
}
@Post('/page', { description: Constants.per.authOnly })
@Post('/page', { description: Constants.per.authOnly, summary: "查询流水线分组分页列表" })
async page(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {};
@@ -38,7 +38,7 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return this.ok(res);
}
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询流水线分组列表" })
async list(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {};
@@ -47,7 +47,7 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return await super.list(body);
}
@Post('/add', { description: Constants.per.authOnly })
@Post('/add', { description: Constants.per.authOnly, summary: "添加流水线分组" })
async add(@Body(ALL) bean: any) {
const {projectId,userId} = await this.getProjectUserIdRead();
bean.userId = userId;
@@ -55,26 +55,26 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return await super.add(bean);
}
@Post('/update', { description: Constants.per.authOnly })
@Post('/update', { description: Constants.per.authOnly, summary: "更新流水线分组" })
async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId;
delete bean.projectId;
return await super.update(bean);
}
@Post('/info', { description: Constants.per.authOnly })
@Post('/info', { description: Constants.per.authOnly, summary: "查询流水线分组详情" })
async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read");
return await super.info(id);
}
@Post('/delete', { description: Constants.per.authOnly })
@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);
}
@Post('/all', { description: Constants.per.authOnly })
@Post('/all', { description: Constants.per.authOnly, summary: "查询所有流水线分组" })
async all() {
const {projectId,userId} = await this.getProjectUserIdRead();
const list: any = await this.service.find({
@@ -18,19 +18,19 @@ export class PluginController extends BaseController {
@Inject()
pluginConfigService: PluginConfigService;
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询插件列表" })
async list(@Query(ALL) query: any) {
const list = await this.service.getEnabledBuiltInList();
return this.ok(list);
}
@Post('/groups', { description: Constants.per.authOnly })
@Post('/groups', { description: Constants.per.authOnly, summary: "查询插件分组" })
async groups(@Query(ALL) query: any) {
const group = await this.service.getEnabledBuildInGroup();
return this.ok(group);
}
@Post('/groupsList', { description: Constants.per.authOnly })
@Post('/groupsList', { description: Constants.per.authOnly, summary: "查询插件分组列表" })
async groupsList(@Query(ALL) query: any) {
const groups = pluginGroups
const groupsList:any = []
@@ -44,13 +44,13 @@ export class PluginController extends BaseController {
return this.ok(groupsList);
}
@Post('/getDefineByType', { description: Constants.per.authOnly })
@Post('/getDefineByType', { description: Constants.per.authOnly, summary: "根据类型获取插件定义" })
async getDefineByType(@Body('type') type: string) {
const define = await this.service.getDefineByType(type);
return this.ok(define);
}
@Post('/config', { description: Constants.per.authOnly })
@Post('/config', { description: Constants.per.authOnly, summary: "获取插件配置" })
async config(@Body(ALL) body: { id?: number; name?: string; type: string }) {
const config = await this.pluginConfigService.getPluginConfig(body);
return this.ok(config);
@@ -22,7 +22,7 @@ export class SubDomainController extends CrudController<SubDomainService> {
return this.service;
}
@Post('/parseDomain', { description: Constants.per.authOnly })
@Post('/parseDomain', { description: Constants.per.authOnly, summary: "解析域名" })
async parseDomain(@Body("fullDomain") fullDomain:string) {
const {projectId,userId} = await this.getProjectUserIdRead();
const taskService = this.taskServiceBuilder.create({ userId: userId, projectId: projectId });
@@ -33,7 +33,7 @@ export class SubDomainController extends CrudController<SubDomainService> {
}
@Post('/page', { description: Constants.per.authOnly })
@Post('/page', { description: Constants.per.authOnly, summary: "查询子域名分页列表" })
async page(@Body(ALL) body) {
const {userId,projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {};
@@ -51,7 +51,7 @@ export class SubDomainController extends CrudController<SubDomainService> {
return this.ok(res);
}
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询子域名列表" })
async list(@Body(ALL) body) {
const {userId,projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {};
@@ -60,7 +60,7 @@ export class SubDomainController extends CrudController<SubDomainService> {
return super.list(body);
}
@Post('/add', { description: Constants.per.authOnly })
@Post('/add', { description: Constants.per.authOnly, summary: "添加子域名" })
async add(@Body(ALL) bean) {
const {userId,projectId} = await this.getProjectUserIdRead();
bean.userId = userId;
@@ -68,26 +68,26 @@ export class SubDomainController extends CrudController<SubDomainService> {
return super.add(bean);
}
@Post('/update', { description: Constants.per.authOnly })
@Post('/update', { description: Constants.per.authOnly, summary: "更新子域名" })
async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId;
delete bean.projectId;
return super.update(bean);
}
@Post('/info', { description: Constants.per.authOnly })
@Post('/info', { description: Constants.per.authOnly, summary: "查询子域名详情" })
async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read");
return super.info(id);
}
@Post('/delete', { description: Constants.per.authOnly })
@Post('/delete', { description: Constants.per.authOnly, summary: "删除子域名" })
async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write");
return super.delete(id);
}
@Post('/batchDelete', { description: Constants.per.authOnly })
@Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除子域名" })
async batchDelete(@Body('ids') ids: number[]) {
const {userId,projectId} = await this.getProjectUserIdWrite();
await this.service.batchDelete(ids, userId, projectId);
@@ -19,7 +19,7 @@ export class TemplateController extends CrudController<TemplateService> {
}
@Post('/page', { description: Constants.per.authOnly })
@Post('/page', { description: Constants.per.authOnly, summary: "查询流水线模版分页列表" })
async page(@Body(ALL) body) {
body.query = body.query ?? {};
@@ -39,7 +39,7 @@ export class TemplateController extends CrudController<TemplateService> {
return this.ok(res);
}
@Post('/list', { description: Constants.per.authOnly })
@Post('/list', { description: Constants.per.authOnly, summary: "查询流水线模版列表" })
async list(@Body(ALL) body) {
body.query = body.query ?? {};
const { projectId, userId } = await this.getProjectUserIdRead()
@@ -48,7 +48,7 @@ export class TemplateController extends CrudController<TemplateService> {
return super.list(body);
}
@Post('/add', { description: Constants.per.authOnly })
@Post('/add', { description: Constants.per.authOnly, summary: "添加流水线模版" })
async add(@Body(ALL) bean) {
const { projectId, userId } = await this.getProjectUserIdRead()
bean.userId = userId;
@@ -57,40 +57,40 @@ export class TemplateController extends CrudController<TemplateService> {
return super.add(bean);
}
@Post('/update', { description: Constants.per.authOnly })
@Post('/update', { description: Constants.per.authOnly, summary: "更新流水线模版" })
async update(@Body(ALL) bean) {
await this.checkOwner(this.service, bean.id, "write");
delete bean.userId;
delete bean.projectId;
return super.update(bean);
}
@Post('/info', { description: Constants.per.authOnly })
@Post('/info', { description: Constants.per.authOnly, summary: "查询流水线模版详情" })
async info(@Query('id') id: number) {
await this.checkOwner(this.service, id, "read");
return super.info(id);
}
@Post('/delete', { description: Constants.per.authOnly })
@Post('/delete', { description: Constants.per.authOnly, summary: "删除流水线模版" })
async delete(@Query('id') id: number) {
const { userId ,projectId } = await this.getProjectUserIdWrite()
await this.service.batchDelete([id], userId,projectId);
return this.ok({});
}
@Post('/batchDelete', { description: Constants.per.authOnly })
@Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除流水线模版" })
async batchDelete(@Body('ids') ids: number[]) {
const { userId ,projectId } = await this.getProjectUserIdWrite()
await this.service.batchDelete(ids, userId,projectId);
return this.ok({});
}
@Post('/detail', { description: Constants.per.authOnly })
@Post('/detail', { description: Constants.per.authOnly, summary: "查询流水线模版详情" })
async detail(@Query('id') id: number) {
const { userId ,projectId } = await this.getProjectUserIdRead()
const detail = await this.service.detail(id, userId,projectId);
return this.ok(detail);
}
@Post('/createPipelineByTemplate', { description: Constants.per.authOnly })
@Post('/createPipelineByTemplate', { description: Constants.per.authOnly, summary: "根据模版创建流水线" })
async createPipelineByTemplate(@Body(ALL) body: any) {
const { userId ,projectId } = await this.getProjectUserIdWrite()
body.userId = userId;