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

View File

@@ -782,7 +782,7 @@ export default {
oauthOnlyHelper: "是否仅使用第三方登录,关闭密码登录(注意:请务必在测试第三方登录功能正常后再开启,否则会导致无法登录)\n 如果无法登录,请访问 http://你的certd地址/#/login?oauthOnly=false 来临时关闭此模式", oauthOnlyHelper: "是否仅使用第三方登录,关闭密码登录(注意:请务必在测试第三方登录功能正常后再开启,否则会导致无法登录)\n 如果无法登录,请访问 http://你的certd地址/#/login?oauthOnly=false 来临时关闭此模式",
enablePasskey: "启用Passkey登录", enablePasskey: "启用Passkey登录",
passkeyHostnameNotSame: "当前域名与主绑定域名不同", passkeyHostnameNotSame: "当前域名与主绑定域名不同",
passkeyEnabledHelper: "1、站点必须启用https \n2、域名不要变否则会导致已注册的passkey失效 \n3、域名以主绑定域名为准当前主域名:{0}", passkeyEnabledHelper: "1、站点必须启用https \n2、passkey的rpId以主绑定域名为准当前主域名:{0} \n3、站点域名不能变否则会导致已注册的passkey失效。",
email: { email: {
templates: "邮件模板", templates: "邮件模板",
templateType: "模板类型", templateType: "模板类型",

View File

@@ -21,8 +21,10 @@ div#app {
height: 100%; height: 100%;
} }
pre.pre { pre{
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; &.pre,&.helper{
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
}
} }
h1, h1,

View File

@@ -122,7 +122,7 @@
<template #icon><fs-icon icon="ion:add-circle-outline" /></template> <template #icon><fs-icon icon="ion:add-circle-outline" /></template>
注册新的Passkey 注册新的Passkey
</a-button> </a-button>
<pre class="helper">{{ t("authentication.passkeyRegisterHelper") }}</pre> <pre class="helper pre">{{ t("authentication.passkeyRegisterHelper") }}</pre>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -50,4 +50,12 @@ export const openkeyApi = {
data: { id }, data: { id },
}); });
}, },
async GetSecret(id: number) {
return await request({
url: apiPrefix + "/getSecret",
method: "post",
data: { id },
});
},
}; };

View File

@@ -145,6 +145,23 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
column: { column: {
width: 580, width: 580,
sorter: true, sorter: true,
cellRender: ({ row, value }) => {
async function getSecret(id: number) {
row.keySecret = await api.GetSecret(id);
}
if (value.includes("*")) {
return (
<div class="flex items-center flex-between">
{value}
<a-button type="primary" size="small" onClick={() => getSecret(row.id)}>
</a-button>
</div>
);
} else {
return <fs-copyable model-value={value}></fs-copyable>;
}
},
}, },
}, },
scope: { scope: {

View File

@@ -122,7 +122,7 @@ const editableKeys = ref([
}, },
defaultRender(item: any) { defaultRender(item: any) {
return () => { return () => {
return <pre class={"helper"}>{item["helper"]}</pre>; return <pre class={"helper pre"}>{item["helper"]}</pre>;
}; };
}, },
editRender(item: any) { editRender(item: any) {

View File

@@ -6,7 +6,7 @@
<a-switch v-model:checked="formState.public.passkeyEnabled" :disabled="!settingsStore.isPlus" :title="t('certd.plusFeature')" /> <a-switch v-model:checked="formState.public.passkeyEnabled" :disabled="!settingsStore.isPlus" :title="t('certd.plusFeature')" />
<vip-button class="ml-5" mode="button"></vip-button> <vip-button class="ml-5" mode="button"></vip-button>
</div> </div>
<pre class="helper">{{ t("certd.sys.setting.passkeyEnabledHelper", [bindDomain]) }}</pre> <pre class="helper pre">{{ t("certd.sys.setting.passkeyEnabledHelper", [bindDomain]) }}</pre>
<div v-if="!bindDomainIsSame" class="text-red-500 text-sm mt-2"> <div v-if="!bindDomainIsSame" class="text-red-500 text-sm mt-2">
{{ t("certd.sys.setting.passkeyHostnameNotSame") }} {{ t("certd.sys.setting.passkeyHostnameNotSame") }}
</div> </div>

View File

@@ -135,7 +135,101 @@ const development = {
isGenerateTagForController: false, isGenerateTagForController: false,
routerFilter: (url: string) => { routerFilter: (url: string) => {
return url.startsWith('/api/sys'); return url.startsWith('/api/sys');
} },
tags: [
{
name: 'addon',
description: '插件管理'
},
{
name: 'basic-group',
description: '基础分组管理'
},
{
name: 'basic-user',
description: '基础用户管理'
},
{
name: 'cert',
description: '证书管理'
},
{
name: 'pipeline-cname',
description: 'CNAME配置管理'
},
{
name: 'dashboard',
description: '仪表板统计'
},
{
name: 'enterprise-project',
description: '企业项目管理'
},
{
name: 'enterprise-project-member',
description: '企业项目成员管理'
},
{
name: 'mine',
description: '个人中心'
},
{
name: 'monitor',
description: '监控管理'
},
{
name: 'open',
description: '开放API KEY管理'
},
{
name: 'pipeline-access',
description: '流水线授权配置'
},
{
name: 'pipeline-cert',
description: '流水线证书'
},
{
name: 'pipeline-dns-provider',
description: '流水线DNS提供商'
},
{
name: 'pipeline-handle',
description: '插件请求处理'
},
{
name: 'pipeline-history',
description: '流水线执行历史'
},
{
name: 'pipeline-notification',
description: '流水线通知配置'
},
{
name: 'pipeline-plugin',
description: '流水线插件'
},
{
name: 'pipeline-subdomain',
description: '流水线子域名'
},
{
name: 'pipeline-template',
description: '流水线模版'
},
{
name: 'pipeline-group',
description: '流水线分组'
},
{
name: 'pipeline',
description: '流水线管理'
},
{
name: 'openapi',
description: '开放API'
},
]
} }
} as MidwayConfig; } as MidwayConfig;
loadDotEnv(); loadDotEnv();

View File

@@ -62,7 +62,10 @@ process.on('uncaughtException', error => {
upload, upload,
libServer, libServer,
commercial, commercial,
swagger, {
component: swagger,
enabledEnvironment: ['local']
},
{ {
component: info, component: info,
enabledEnvironment: ['local'], enabledEnvironment: ['local'],

View File

@@ -25,8 +25,8 @@ export class OpenCertController extends BaseOpenController {
@Inject() @Inject()
encryptService: EncryptService; encryptService: EncryptService;
@Get('/get', { description: Constants.per.open }) @Get('/get', { description: Constants.per.open, summary: "根据域名或ID获取证书支持自动申请" })
@Post('/get', { description: Constants.per.open }) @Post('/get', { description: Constants.per.open, summary: "根据域名或ID获取证书支持自动申请" })
async get(@Body(ALL) bean: CertGetReq, @Query(ALL) query: CertGetReq) { async get(@Body(ALL) bean: CertGetReq, @Query(ALL) query: CertGetReq) {
const openKey: OpenKey = this.ctx.openKey; const openKey: OpenKey = this.ctx.openKey;
const userId = openKey.userId; const userId = openKey.userId;

View File

@@ -32,7 +32,7 @@ export class AddonController extends CrudController<AddonService> {
return this.service; return this.service;
} }
@Post("/page", { description: Constants.per.authOnly }) @Post("/page", { description: Constants.per.authOnly, summary: "查询Addon分页列表" })
async page(@Body(ALL) body) { async page(@Body(ALL) body) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -50,7 +50,7 @@ export class AddonController extends CrudController<AddonService> {
return this.ok(res); return this.ok(res);
} }
@Post("/list", { description: Constants.per.authOnly }) @Post("/list", { description: Constants.per.authOnly, summary: "查询Addon列表" })
async list(@Body(ALL) body) { async list(@Body(ALL) body) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -59,7 +59,7 @@ export class AddonController extends CrudController<AddonService> {
return super.list(body); return super.list(body);
} }
@Post("/add", { description: Constants.per.authOnly }) @Post("/add", { description: Constants.per.authOnly, summary: "添加Addon" })
async add(@Body(ALL) bean) { async add(@Body(ALL) bean) {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
bean.userId = userId; bean.userId = userId;
@@ -79,7 +79,7 @@ export class AddonController extends CrudController<AddonService> {
return super.add(bean); return super.add(bean);
} }
@Post("/update", { description: Constants.per.authOnly }) @Post("/update", { description: Constants.per.authOnly, summary: "更新Addon" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
const old = await this.service.info(bean.id); const old = await this.service.info(bean.id);
@@ -102,25 +102,25 @@ export class AddonController extends CrudController<AddonService> {
return super.update(bean); return super.update(bean);
} }
@Post("/info", { description: Constants.per.authOnly }) @Post("/info", { description: Constants.per.authOnly, summary: "查询Addon详情" })
async info(@Query("id") id: number) { async info(@Query("id") id: number) {
await this.checkOwner(this.getService(), id, "read"); await this.checkOwner(this.getService(), id, "read");
return super.info(id); return super.info(id);
} }
@Post("/delete", { description: Constants.per.authOnly }) @Post("/delete", { description: Constants.per.authOnly, summary: "删除Addon" })
async delete(@Query("id") id: number) { async delete(@Query("id") id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return super.delete(id); return super.delete(id);
} }
@Post("/define", { description: Constants.per.authOnly }) @Post("/define", { description: Constants.per.authOnly, summary: "查询Addon插件定义" })
async define(@Query("type") type: string, @Query("addonType") addonType: string) { async define(@Query("type") type: string, @Query("addonType") addonType: string) {
const notification = this.service.getDefineByType(type, addonType); const notification = this.service.getDefineByType(type, addonType);
return this.ok(notification); return this.ok(notification);
} }
@Post("/getTypeDict", { description: Constants.per.authOnly }) @Post("/getTypeDict", { description: Constants.per.authOnly, summary: "查询Addon插件类型字典" })
async getTypeDict(@Query("addonType") addonType: string) { async getTypeDict(@Query("addonType") addonType: string) {
const list: any = this.service.getDefineList(addonType); const list: any = this.service.getDefineList(addonType);
let dict = []; let dict = [];
@@ -138,7 +138,7 @@ export class AddonController extends CrudController<AddonService> {
return this.ok(dict); return this.ok(dict);
} }
@Post("/simpleInfo", { description: Constants.per.authOnly }) @Post("/simpleInfo", { description: Constants.per.authOnly, summary: "查询Addon插件简单信息" })
async simpleInfo(@Query("addonType") addonType: string, @Query("id") id: number) { async simpleInfo(@Query("addonType") addonType: string, @Query("id") id: number) {
if (id === 0) { if (id === 0) {
//获取默认 //获取默认
@@ -155,14 +155,14 @@ export class AddonController extends CrudController<AddonService> {
return this.ok(res); return this.ok(res);
} }
@Post("/getDefaultId", { description: Constants.per.authOnly }) @Post("/getDefaultId", { description: Constants.per.authOnly, summary: "查询Addon插件默认配置ID" })
async getDefaultId(@Query("addonType") addonType: string) { async getDefaultId(@Query("addonType") addonType: string) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.getDefault(userId, addonType,projectId); const res = await this.service.getDefault(userId, addonType,projectId);
return this.ok(res?.id); return this.ok(res?.id);
} }
@Post("/setDefault", { description: Constants.per.authOnly }) @Post("/setDefault", { description: Constants.per.authOnly, summary: "设置Addon插件默认配置" })
async setDefault(@Query("addonType") addonType: string, @Query("id") id: number) { async setDefault(@Query("addonType") addonType: string, @Query("id") id: number) {
const {projectId,userId} = await this.checkOwner(this.getService(), id, "write",true); const {projectId,userId} = await this.checkOwner(this.getService(), id, "write",true);
const res = await this.service.setDefault(id, userId, addonType,projectId); const res = await this.service.setDefault(id, userId, addonType,projectId);
@@ -170,7 +170,7 @@ export class AddonController extends CrudController<AddonService> {
} }
@Post("/options", { description: Constants.per.authOnly }) @Post("/options", { description: Constants.per.authOnly, summary: "查询Addon插件配置字典" })
async options(@Query("addonType") addonType: string) { async options(@Query("addonType") addonType: string) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.list({ const res = await this.service.list({
@@ -187,7 +187,7 @@ export class AddonController extends CrudController<AddonService> {
} }
@Post("/handle", { description: Constants.per.authOnly }) @Post("/handle", { description: Constants.per.authOnly, summary: "Addon插件处理请求" })
async handle(@Body(ALL) body: AddonRequestHandleReq) { async handle(@Body(ALL) body: AddonRequestHandleReq) {
let inputAddon = body.input.addon; let inputAddon = body.input.addon;
if (body.input.id > 0) { if (body.input.id > 0) {

View File

@@ -20,7 +20,7 @@ export class GroupController extends CrudController<GroupService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询分组分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -38,7 +38,7 @@ export class GroupController extends CrudController<GroupService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询分组列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -47,7 +47,7 @@ export class GroupController extends CrudController<GroupService> {
return await super.list(body); return await super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加分组" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
bean.projectId = projectId; bean.projectId = projectId;
@@ -55,26 +55,26 @@ export class GroupController extends CrudController<GroupService> {
return await super.add(bean); return await super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新分组" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId; delete bean.userId;
delete bean.projectId; delete bean.projectId;
return await super.update(bean); return await super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询分组详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read"); await this.checkOwner(this.getService(), id, "read");
return await super.info(id); return await super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除分组" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return await super.delete(id); return await super.delete(id);
} }
@Post('/all', { description: Constants.per.authOnly }) @Post('/all', { description: Constants.per.authOnly, summary: "查询所有分组" })
async all(@Query('type') type: string) { async all(@Query('type') type: string) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const list: any = await this.service.find({ const list: any = await this.service.find({

View File

@@ -25,7 +25,7 @@ export class BasicUserController extends BasicController {
return this.service; return this.service;
} }
@Post('/getSimpleUserByIds', { description: Constants.per.authOnly }) @Post('/getSimpleUserByIds', { description: Constants.per.authOnly, summary: "根据ID列表获取用户简单信息" })
async getSimpleUserByIds(@Body('ids') ids: number[]) { async getSimpleUserByIds(@Body('ids') ids: number[]) {
if(!isEnterprise()){ if(!isEnterprise()){
throw new Error('非企业模式不能获取用户信息'); throw new Error('非企业模式不能获取用户信息');
@@ -45,7 +45,7 @@ export class BasicUserController extends BasicController {
return this.ok(users); return this.ok(users);
} }
@Post('/getSimpleUsers', {description: Constants.per.authOnly}) @Post('/getSimpleUsers', {description: Constants.per.authOnly, summary: "获取所有用户简单信息"})
async getSimpleUsers() { async getSimpleUsers() {
if(!isEnterprise()){ if(!isEnterprise()){
throw new Error('非企业模式不能获取所有用户信息'); throw new Error('非企业模式不能获取所有用户信息');
@@ -62,7 +62,7 @@ export class BasicUserController extends BasicController {
return this.ok(users); return this.ok(users);
} }
@Post('/getSimpleRoles', {description: Constants.per.authOnly}) @Post('/getSimpleRoles', {description: Constants.per.authOnly, summary: "获取所有角色简单信息"})
async getSimpleRoles() { async getSimpleRoles() {
const roles = await this.roleService.find({ const roles = await this.roleService.find({
select: { select: {

View File

@@ -18,7 +18,7 @@ export class DomainController extends CrudController<DomainService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询域名分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -42,7 +42,7 @@ export class DomainController extends CrudController<DomainService> {
return this.ok(pageRet); return this.ok(pageRet);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询域名列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -52,7 +52,7 @@ export class DomainController extends CrudController<DomainService> {
return this.ok(list); return this.ok(list);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加域名" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
bean.projectId = projectId; bean.projectId = projectId;
@@ -60,7 +60,7 @@ export class DomainController extends CrudController<DomainService> {
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新域名" })
async update(@Body(ALL) bean: any) { async update(@Body(ALL) bean: any) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId; delete bean.userId;
@@ -68,19 +68,19 @@ export class DomainController extends CrudController<DomainService> {
return super.update(bean); return super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询域名详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read"); await this.checkOwner(this.getService(), id, "read");
return super.info(id); return super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除域名" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return super.delete(id); return super.delete(id);
} }
@Post('/deleteByIds', { description: Constants.per.authOnly }) @Post('/deleteByIds', { description: Constants.per.authOnly, summary: "批量删除域名" })
async deleteByIds(@Body(ALL) body: any) { async deleteByIds(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
await this.service.delete(body.ids, { await this.service.delete(body.ids, {
@@ -91,7 +91,7 @@ export class DomainController extends CrudController<DomainService> {
} }
@Post('/import/start', { description: Constants.per.authOnly }) @Post('/import/start', { description: Constants.per.authOnly, summary: "开始域名导入任务" })
async importStart(@Body(ALL) body: any) { async importStart(@Body(ALL) body: any) {
checkPlus(); checkPlus();
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
@@ -105,7 +105,7 @@ export class DomainController extends CrudController<DomainService> {
return this.ok(); return this.ok();
} }
@Post('/import/status', { description: Constants.per.authOnly }) @Post('/import/status', { description: Constants.per.authOnly, summary: "查询域名导入任务状态" })
async importStatus() { async importStatus() {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const req = { const req = {
@@ -117,7 +117,7 @@ export class DomainController extends CrudController<DomainService> {
} }
@Post('/import/delete', { description: Constants.per.authOnly }) @Post('/import/delete', { description: Constants.per.authOnly, summary: "删除域名导入任务" })
async importDelete(@Body(ALL) body: any) { async importDelete(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const { key } = body; const { key } = body;
@@ -130,7 +130,7 @@ export class DomainController extends CrudController<DomainService> {
return this.ok(); return this.ok();
} }
@Post('/import/save', { description: Constants.per.authOnly }) @Post('/import/save', { description: Constants.per.authOnly, summary: "保存域名导入任务" })
async importSave(@Body(ALL) body: any) { async importSave(@Body(ALL) body: any) {
checkPlus(); checkPlus();
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
@@ -145,7 +145,7 @@ export class DomainController extends CrudController<DomainService> {
} }
@Post('/sync/expiration/start', { description: Constants.per.authOnly }) @Post('/sync/expiration/start', { description: Constants.per.authOnly, summary: "开始同步域名过期时间任务" })
async syncExpirationStart(@Body(ALL) body: any) { async syncExpirationStart(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
await this.service.startSyncExpirationTask({ await this.service.startSyncExpirationTask({
@@ -154,7 +154,7 @@ export class DomainController extends CrudController<DomainService> {
}) })
return this.ok(); return this.ok();
} }
@Post('/sync/expiration/status', { description: Constants.per.authOnly }) @Post('/sync/expiration/status', { description: Constants.per.authOnly, summary: "查询同步域名过期时间任务状态" })
async syncExpirationStatus(@Body(ALL) body: any) { async syncExpirationStatus(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const status = await this.service.getSyncExpirationTaskStatus({ const status = await this.service.getSyncExpirationTaskStatus({

View File

@@ -20,7 +20,7 @@ export class CnameProviderController extends BaseController {
return this.service; return this.service;
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询CNAME提供商列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const res = await this.providerService.list({}); const res = await this.providerService.list({});
return this.ok(res); return this.ok(res);

View File

@@ -17,7 +17,7 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询CNAME记录分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -41,7 +41,7 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
return this.ok(pageRet); return this.ok(pageRet);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询CNAME记录列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -51,7 +51,7 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
return this.ok(list); return this.ok(list);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加CNAME记录" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const {userId,projectId} = await this.getProjectUserIdWrite(); const {userId,projectId} = await this.getProjectUserIdWrite();
bean.userId = userId; bean.userId = userId;
@@ -59,7 +59,7 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新CNAME记录" })
async update(@Body(ALL) bean: any) { async update(@Body(ALL) bean: any) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId; delete bean.userId;
@@ -67,19 +67,19 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
return super.update(bean); return super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询CNAME记录详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read"); await this.checkOwner(this.getService(), id, "read");
return super.info(id); return super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除CNAME记录" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return super.delete(id); return super.delete(id);
} }
@Post('/deleteByIds', { description: Constants.per.authOnly }) @Post('/deleteByIds', { description: Constants.per.authOnly, summary: "批量删除CNAME记录" })
async deleteByIds(@Body(ALL) body: any) { async deleteByIds(@Body(ALL) body: any) {
const {userId,projectId} = await this.getProjectUserIdWrite(); const {userId,projectId} = await this.getProjectUserIdWrite();
await this.service.delete(body.ids, { await this.service.delete(body.ids, {
@@ -88,27 +88,27 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
}); });
return this.ok(); return this.ok();
} }
@Post('/getByDomain', { description: Constants.per.authOnly }) @Post('/getByDomain', { description: Constants.per.authOnly, summary: "根据域名获取CNAME记录" })
async getByDomain(@Body(ALL) body: { domain: string; createOnNotFound: boolean }) { async getByDomain(@Body(ALL) body: { domain: string; createOnNotFound: boolean }) {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
const res = await this.service.getByDomain(body.domain, userId,projectId, body.createOnNotFound); const res = await this.service.getByDomain(body.domain, userId,projectId, body.createOnNotFound);
return this.ok(res); return this.ok(res);
} }
@Post('/verify', { description: Constants.per.authOnly }) @Post('/verify', { description: Constants.per.authOnly, summary: "验证CNAME记录" })
async verify(@Body(ALL) body: { id: number }) { async verify(@Body(ALL) body: { id: number }) {
await this.checkOwner(this.getService(), body.id, "read"); await this.checkOwner(this.getService(), body.id, "read");
const res = await this.service.verify(body.id); const res = await this.service.verify(body.id);
return this.ok(res); return this.ok(res);
} }
@Post('/resetStatus', { description: Constants.per.authOnly }) @Post('/resetStatus', { description: Constants.per.authOnly, summary: "重置CNAME记录状态" })
async resetStatus(@Body(ALL) body: { id: number }) { async resetStatus(@Body(ALL) body: { id: number }) {
await this.checkOwner(this.getService(), body.id, "read"); await this.checkOwner(this.getService(), body.id, "read");
const res = await this.service.resetStatus(body.id); const res = await this.service.resetStatus(body.id);
return this.ok(res); return this.ok(res);
} }
@Post('/import', { description: Constants.per.authOnly }) @Post('/import', { description: Constants.per.authOnly, summary: "导入CNAME记录" })
async import(@Body(ALL) body: { domainList: string; cnameProviderId: any }) { async import(@Body(ALL) body: { domainList: string; cnameProviderId: any }) {
const {userId,projectId} = await this.getProjectUserIdWrite(); const {userId,projectId} = await this.getProjectUserIdWrite();
const res = await this.service.doImport({ const res = await this.service.doImport({

View File

@@ -46,7 +46,7 @@ export class StatisticController extends BaseController {
@Inject() @Inject()
certInfoService: CertInfoService; certInfoService: CertInfoService;
@Post('/count', { description: Constants.per.authOnly }) @Post('/count', { description: Constants.per.authOnly, summary: "查询仪表盘统计数据" })
public async count() { public async count() {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
const pipelineCount = await this.pipelineService.count({ userId,projectId }); const pipelineCount = await this.pipelineService.count({ userId,projectId });

View File

@@ -28,7 +28,7 @@ export class UserProjectController extends BaseController {
* @param body * @param body
* @returns * @returns
*/ */
@Post('/detail', { description: Constants.per.authOnly }) @Post('/detail', { description: Constants.per.authOnly, summary: "查询项目详情" })
async detail(@Body(ALL) body: any) { async detail(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdRead(); const {projectId} = await this.getProjectUserIdRead();
const res = await this.service.getDetail(projectId,this.getUserId()); const res = await this.service.getDetail(projectId,this.getUserId());
@@ -41,7 +41,7 @@ export class UserProjectController extends BaseController {
* @param body * @param body
* @returns * @returns
*/ */
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询我的项目列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const userId= this.getUserId(); const userId= this.getUserId();
const res = await this.service.getUserProjects(userId); const res = await this.service.getUserProjects(userId);
@@ -54,21 +54,21 @@ export class UserProjectController extends BaseController {
* @param body 所有项目 * @param body 所有项目
* @returns * @returns
*/ */
@Post('/all', { description: Constants.per.authOnly }) @Post('/all', { description: Constants.per.authOnly, summary: "查询所有项目" })
async all(@Body(ALL) body: any) { async all(@Body(ALL) body: any) {
const userId= this.getUserId(); const userId= this.getUserId();
const res = await this.service.getAllWithStatus(userId); const res = await this.service.getAllWithStatus(userId);
return this.ok(res); return this.ok(res);
} }
@Post('/applyJoin', { description: Constants.per.authOnly }) @Post('/applyJoin', { description: Constants.per.authOnly, summary: "申请加入项目" })
async applyJoin(@Body(ALL) body: any) { async applyJoin(@Body(ALL) body: any) {
const userId= this.getUserId(); const userId= this.getUserId();
const res = await this.service.applyJoin({ userId, projectId: body.projectId }); const res = await this.service.applyJoin({ userId, projectId: body.projectId });
return this.ok(res); return this.ok(res);
} }
@Post('/updateMember', { description: Constants.per.authOnly }) @Post('/updateMember', { description: Constants.per.authOnly, summary: "更新项目成员" })
async updateMember(@Body(ALL) body: any) { async updateMember(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdAdmin(); const {projectId} = await this.getProjectUserIdAdmin();
const {status,permission,userId} = body; const {status,permission,userId} = body;
@@ -89,7 +89,7 @@ export class UserProjectController extends BaseController {
return this.ok(res); return this.ok(res);
} }
@Post('/approveJoin', { description: Constants.per.authOnly }) @Post('/approveJoin', { description: Constants.per.authOnly, summary: "审批加入项目申请" })
async approveJoin(@Body(ALL) body: any) { async approveJoin(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdAdmin(); const {projectId} = await this.getProjectUserIdAdmin();
const {status,permission,userId} = body; const {status,permission,userId} = body;
@@ -97,7 +97,7 @@ export class UserProjectController extends BaseController {
return this.ok(res); return this.ok(res);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除项目成员" })
async delete(@Body(ALL) body: any) { async delete(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdAdmin(); const {projectId} = await this.getProjectUserIdAdmin();
await this.projectMemberService.deleteWhere({ await this.projectMemberService.deleteWhere({
@@ -107,7 +107,7 @@ export class UserProjectController extends BaseController {
return this.ok(); return this.ok();
} }
@Post('/leave', { description: Constants.per.authOnly }) @Post('/leave', { description: Constants.per.authOnly, summary: "离开项目" })
async leave(@Body(ALL) body: any) { async leave(@Body(ALL) body: any) {
const {projectId} = body const {projectId} = body
const userId = this.getUserId(); const userId = this.getUserId();

View File

@@ -24,7 +24,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return this.service; return this.service;
} }
@Post("/page", { description: Constants.per.authOnly }) @Post("/page", { description: Constants.per.authOnly, summary: "查询项目成员分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdRead(); const {projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -32,7 +32,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return await super.page(body); return await super.page(body);
} }
@Post("/list", { description: Constants.per.authOnly }) @Post("/list", { description: Constants.per.authOnly, summary: "查询项目成员列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdRead(); const {projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -40,7 +40,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return super.list(body); return super.list(body);
} }
@Post("/add", { description: Constants.per.authOnly }) @Post("/add", { description: Constants.per.authOnly, summary: "添加项目成员" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const def: any = { const def: any = {
isDefault: false, isDefault: false,
@@ -56,7 +56,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return super.add(bean); return super.add(bean);
} }
@Post("/update", { description: Constants.per.authOnly }) @Post("/update", { description: Constants.per.authOnly, summary: "更新项目成员" })
async update(@Body(ALL) bean: any) { async update(@Body(ALL) bean: any) {
if (!bean.id) { if (!bean.id) {
throw new Error("id is required"); throw new Error("id is required");
@@ -75,7 +75,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return this.ok(res); return this.ok(res);
} }
@Post("/info", { description: Constants.per.authOnly }) @Post("/info", { description: Constants.per.authOnly, summary: "查询项目成员详情" })
async info(@Query("id") id: number) { async info(@Query("id") id: number) {
if (!id) { if (!id) {
throw new Error("id is required"); throw new Error("id is required");
@@ -88,7 +88,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return super.info(id); return super.info(id);
} }
@Post("/delete", { description: Constants.per.authOnly }) @Post("/delete", { description: Constants.per.authOnly, summary: "删除项目成员" })
async delete(@Query("id") id: number) { async delete(@Query("id") id: number) {
if (!id) { if (!id) {
throw new Error("id is required"); throw new Error("id is required");
@@ -101,7 +101,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return super.delete(id); return super.delete(id);
} }
@Post("/deleteByIds", { description: Constants.per.authOnly }) @Post("/deleteByIds", { description: Constants.per.authOnly, summary: "批量删除项目成员" })
async deleteByIds(@Body("ids") ids: number[]) { async deleteByIds(@Body("ids") ids: number[]) {
for (const id of ids) { for (const id of ids) {
if (!id) { if (!id) {

View File

@@ -22,7 +22,7 @@ export class TransferController extends BaseController {
* @param body * @param body
* @returns * @returns
*/ */
@Post('/selfResources', { description: Constants.per.authOnly }) @Post('/selfResources', { description: Constants.per.authOnly, summary: "查询我自己的资源" })
async selfResources() { async selfResources() {
const userId = this.getUserId(); const userId = this.getUserId();
const res = await this.service.getUserResources(userId); const res = await this.service.getUserResources(userId);
@@ -34,7 +34,7 @@ export class TransferController extends BaseController {
* @param body * @param body
* @returns * @returns
*/ */
@Post('/doTransfer', { description: Constants.per.authOnly }) @Post('/doTransfer', { description: Constants.per.authOnly, summary: "迁移项目资源" })
async doTransfer() { async doTransfer() {
const {projectId} = await this.getProjectUserIdRead(); const {projectId} = await this.getProjectUserIdRead();
const userId = this.getUserId(); const userId = this.getUserId();

View File

@@ -13,28 +13,28 @@ export class EmailController extends BaseController {
@Inject() @Inject()
emailService: EmailService; emailService: EmailService;
@Post('/test', { description: Constants.per.authOnly }) @Post('/test', { description: Constants.per.authOnly, summary: "测试邮件发送" })
public async test(@Body('receiver') receiver) { public async test(@Body('receiver') receiver) {
const userId = super.getUserId(); const userId = super.getUserId();
await this.emailService.test(userId, receiver); await this.emailService.test(userId, receiver);
return this.ok({}); return this.ok({});
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询邮件列表" })
public async list() { public async list() {
const userId = super.getUserId(); const userId = super.getUserId();
const res = await this.emailService.list(userId); const res = await this.emailService.list(userId);
return this.ok(res); return this.ok(res);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加邮件" })
public async add(@Body('email') email) { public async add(@Body('email') email) {
const userId = super.getUserId(); const userId = super.getUserId();
await this.emailService.add(userId, email); await this.emailService.add(userId, email);
return this.ok({}); return this.ok({});
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除邮件" })
public async delete(@Body('email') email) { public async delete(@Body('email') email) {
const userId = super.getUserId(); const userId = super.getUserId();
await this.emailService.delete(userId, email); await this.emailService.delete(userId, email);

View File

@@ -21,7 +21,7 @@ export class MineController extends BaseController {
passkeyService: PasskeyService; passkeyService: PasskeyService;
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询用户信息" })
public async info() { public async info() {
const userId = this.getUserId(); const userId = this.getUserId();
const user = await this.userService.info(userId); const user = await this.userService.info(userId);
@@ -35,14 +35,14 @@ export class MineController extends BaseController {
return this.ok(user); return this.ok(user);
} }
@Post('/changePassword', { description: Constants.per.authOnly }) @Post('/changePassword', { description: Constants.per.authOnly, summary: "修改密码" })
public async changePassword(@Body(ALL) body: any) { public async changePassword(@Body(ALL) body: any) {
const userId = this.getUserId(); const userId = this.getUserId();
await this.userService.changePassword(userId, body); await this.userService.changePassword(userId, body);
return this.ok({}); return this.ok({});
} }
@Post('/updateProfile', { description: Constants.per.authOnly }) @Post('/updateProfile', { description: Constants.per.authOnly, summary: "更新用户资料" })
public async updateProfile(@Body(ALL) body: any) { public async updateProfile(@Body(ALL) body: any) {
const userId = this.getUserId(); const userId = this.getUserId();

View File

@@ -14,7 +14,7 @@ export class MinePasskeyController extends BaseController {
@Inject() @Inject()
userService: UserService; userService: UserService;
@Post('/generateRegistration', { description: Constants.per.authOnly }) @Post('/generateRegistration', { description: Constants.per.authOnly, summary: "生成Passkey注册选项" })
public async generateRegistration( public async generateRegistration(
@Body(ALL) @Body(ALL)
body: any, body: any,
@@ -41,7 +41,7 @@ export class MinePasskeyController extends BaseController {
}); });
} }
@Post('/verifyRegistration', { description: Constants.per.authOnly }) @Post('/verifyRegistration', { description: Constants.per.authOnly, summary: "验证Passkey注册" })
public async verifyRegistration( public async verifyRegistration(
@Body(ALL) @Body(ALL)
body: any body: any
@@ -64,7 +64,7 @@ export class MinePasskeyController extends BaseController {
@Post('/register', { description: Constants.per.authOnly }) @Post('/register', { description: Constants.per.authOnly, summary: "注册Passkey" })
public async registerPasskey( public async registerPasskey(
@Body(ALL) @Body(ALL)
body: any body: any
@@ -86,7 +86,7 @@ export class MinePasskeyController extends BaseController {
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询Passkey列表" })
public async getPasskeys() { public async getPasskeys() {
const userId = this.getUserId(); const userId = this.getUserId();
const passkeys = await this.passkeyService.find({ const passkeys = await this.passkeyService.find({
@@ -97,7 +97,7 @@ export class MinePasskeyController extends BaseController {
return this.ok(passkeys); return this.ok(passkeys);
} }
@Post('/unbind', { description: Constants.per.authOnly }) @Post('/unbind', { description: Constants.per.authOnly, summary: "解绑Passkey" })
public async unbindPasskey(@Body(ALL) body: any) { public async unbindPasskey(@Body(ALL) body: any) {
const userId = this.getUserId(); const userId = this.getUserId();
const passkeyId = body.id; const passkeyId = body.id;

View File

@@ -21,14 +21,14 @@ export class UserTwoFactorSettingController extends BaseController {
@Post("/get", { description: Constants.per.authOnly }) @Post("/get", { description: Constants.per.authOnly, summary: "获取双因子认证设置" })
async get() { async get() {
const userId = this.getUserId(); const userId = this.getUserId();
const setting = await this.service.getSetting<UserTwoFactorSetting>(userId,null, UserTwoFactorSetting); const setting = await this.service.getSetting<UserTwoFactorSetting>(userId,null, UserTwoFactorSetting);
return this.ok(setting); return this.ok(setting);
} }
@Post("/save", { description: Constants.per.authOnly }) @Post("/save", { description: Constants.per.authOnly, summary: "保存双因子认证设置" })
async save(@Body(ALL) bean: any) { async save(@Body(ALL) bean: any) {
if (!isPlus()) { if (!isPlus()) {
throw new Error('本功能需要开通专业版') throw new Error('本功能需要开通专业版')
@@ -47,14 +47,14 @@ export class UserTwoFactorSettingController extends BaseController {
return this.ok({}); return this.ok({});
} }
@Post("/authenticator/qrcode", { description: Constants.per.authOnly }) @Post("/authenticator/qrcode", { description: Constants.per.authOnly, summary: "获取验证器二维码" })
async authenticatorQrcode() { async authenticatorQrcode() {
const userId = this.getUserId(); const userId = this.getUserId();
const {qrcode,link,secret} = await this.twoFactorService.getAuthenticatorQrCode(userId); const {qrcode,link,secret} = await this.twoFactorService.getAuthenticatorQrCode(userId);
return this.ok({qrcode,link,secret}); return this.ok({qrcode,link,secret});
} }
@Post("/authenticator/save", { description: Constants.per.authOnly }) @Post("/authenticator/save", { description: Constants.per.authOnly, summary: "保存验证器设置" })
async authenticatorSave(@Body(ALL) bean: any) { async authenticatorSave(@Body(ALL) bean: any) {
if (!isPlus()) { if (!isPlus()) {
throw new Error('本功能需要开通专业版') throw new Error('本功能需要开通专业版')
@@ -67,7 +67,7 @@ export class UserTwoFactorSettingController extends BaseController {
return this.ok(); return this.ok();
} }
@Post("/authenticator/off", { description: Constants.per.authOnly }) @Post("/authenticator/off", { description: Constants.per.authOnly, summary: "关闭验证器" })
async authenticatorOff() { async authenticatorOff() {
const userId = this.getUserId(); const userId = this.getUserId();
await this.twoFactorService.offAuthenticator(userId); await this.twoFactorService.offAuthenticator(userId);

View File

@@ -20,65 +20,65 @@ export class UserSettingsController extends CrudController<UserSettingsService>
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询用户设置分页列表" })
async page(@Body(ALL) body) { async page(@Body(ALL) body) {
body.query = body.query ?? {}; body.query = body.query ?? {};
body.query.userId = this.getUserId(); body.query.userId = this.getUserId();
return super.page(body); return super.page(body);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询用户设置列表" })
async list(@Body(ALL) body) { async list(@Body(ALL) body) {
body.query = body.query ?? {}; body.query = body.query ?? {};
body.query.userId = this.getUserId(); body.query.userId = this.getUserId();
return super.list(body); return super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加用户设置" })
async add(@Body(ALL) bean) { async add(@Body(ALL) bean) {
bean.userId = this.getUserId(); bean.userId = this.getUserId();
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新用户设置" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.service.checkUserId(bean.id, this.getUserId()); await this.service.checkUserId(bean.id, this.getUserId());
delete bean.userId; delete bean.userId;
return super.update(bean); return super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询用户设置详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.service.checkUserId(id, this.getUserId()); await this.service.checkUserId(id, this.getUserId());
return super.info(id); return super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除用户设置" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.service.checkUserId(id, this.getUserId()); await this.service.checkUserId(id, this.getUserId());
return super.delete(id); return super.delete(id);
} }
@Post('/save', { description: Constants.per.authOnly }) @Post('/save', { description: Constants.per.authOnly, summary: "保存用户设置" })
async save(@Body(ALL) bean: UserSettingsEntity) { async save(@Body(ALL) bean: UserSettingsEntity) {
bean.userId = this.getUserId(); bean.userId = this.getUserId();
await this.service.save(bean); await this.service.save(bean);
return this.ok({}); return this.ok({});
} }
@Post('/get', { description: Constants.per.authOnly }) @Post('/get', { description: Constants.per.authOnly, summary: "获取用户设置" })
async get(@Query('key') key: string) { async get(@Query('key') key: string) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const entity = await this.service.getByKey(key, userId, projectId); const entity = await this.service.getByKey(key, userId, projectId);
return this.ok(entity); return this.ok(entity);
} }
@Post("/grant/get", { description: Constants.per.authOnly }) @Post("/grant/get", { description: Constants.per.authOnly, summary: "获取授权设置" })
async grantSettingsGet() { async grantSettingsGet() {
const userId = this.getUserId(); const userId = this.getUserId();
const setting = await this.service.getSetting<UserGrantSetting>(userId, null, UserGrantSetting); const setting = await this.service.getSetting<UserGrantSetting>(userId, null, UserGrantSetting);
return this.ok(setting); return this.ok(setting);
} }
@Post("/grant/save", { description: Constants.per.authOnly }) @Post("/grant/save", { description: Constants.per.authOnly, summary: "保存授权设置" })
async grantSettingsSave(@Body(ALL) bean: UserGrantSetting) { async grantSettingsSave(@Body(ALL) bean: UserGrantSetting) {
if (!isPlus()) { if (!isPlus()) {
throw new Error('本功能需要开通专业版') throw new Error('本功能需要开通专业版')

View File

@@ -29,7 +29,7 @@ export class CertInfoController extends CrudController<CertInfoService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询证书分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -78,7 +78,7 @@ export class CertInfoController extends CrudController<CertInfoService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询证书列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
body.query = body.query ?? {}; body.query = body.query ?? {};
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
@@ -88,7 +88,7 @@ export class CertInfoController extends CrudController<CertInfoService> {
} }
@Post('/getOptionsByIds', { description: Constants.per.authOnly }) @Post('/getOptionsByIds', { description: Constants.per.authOnly, summary: "根据ID列表获取证书选项" })
async getOptionsByIds(@Body(ALL) body: {ids:any[]}) { async getOptionsByIds(@Body(ALL) body: {ids:any[]}) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
const list = await this.service.list({ const list = await this.service.list({
@@ -113,7 +113,7 @@ export class CertInfoController extends CrudController<CertInfoService> {
return this.ok(safeList); return this.ok(safeList);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加证书" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const { projectId, userId } = await this.getProjectUserIdWrite() const { projectId, userId } = await this.getProjectUserIdWrite()
bean.projectId = projectId bean.projectId = projectId
@@ -121,26 +121,26 @@ export class CertInfoController extends CrudController<CertInfoService> {
return await super.add(bean); return await super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新证书" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.service,bean.id,"write"); await this.checkOwner(this.service,bean.id,"write");
delete bean.userId; delete bean.userId;
delete bean.projectId; delete bean.projectId;
return await super.update(bean); return await super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询证书详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.service,id,"read"); await this.checkOwner(this.service,id,"read");
return await super.info(id); return await super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除证书" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.service,id,"write"); await this.checkOwner(this.service,id,"write");
return await super.delete(id); return await super.delete(id);
} }
@Post('/all', { description: Constants.per.authOnly }) @Post('/all', { description: Constants.per.authOnly, summary: "查询所有证书" })
async all() { async all() {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
const list: any = await this.service.find({ const list: any = await this.service.find({
@@ -154,7 +154,7 @@ export class CertInfoController extends CrudController<CertInfoService> {
@Post('/getCert', { description: Constants.per.authOnly }) @Post('/getCert', { description: Constants.per.authOnly, summary: "获取证书信息" })
async getCert(@Query('id') id: number) { async getCert(@Query('id') id: number) {
await this.checkOwner(this.getService(),id,"read"); await this.checkOwner(this.getService(),id,"read");
const certInfoEntity = await this.service.info(id); const certInfoEntity = await this.service.info(id);
@@ -162,7 +162,7 @@ export class CertInfoController extends CrudController<CertInfoService> {
return this.ok(certInfo); return this.ok(certInfo);
} }
@Get('/download', { description: Constants.per.authOnly }) @Get('/download', { description: Constants.per.authOnly, summary: "下载证书文件" })
async download(@Query('id') id: number) { async download(@Query('id') id: number) {
const {userId,projectId} =await this.checkOwner(this.getService(),id,"read"); const {userId,projectId} =await this.checkOwner(this.getService(),id,"read");
const certInfo = await this.getService().info(id) const certInfo = await this.getService().info(id)

View File

@@ -25,7 +25,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询站点监控分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
body.query = body.query ?? {}; body.query = body.query ?? {};
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
@@ -56,7 +56,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询站点监控列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
body.query = body.query ?? {}; body.query = body.query ?? {};
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
@@ -65,7 +65,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return await super.list(body); return await super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加站点监控" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const { projectId, userId } = await this.getProjectUserIdWrite() const { projectId, userId } = await this.getProjectUserIdWrite()
bean.projectId = projectId bean.projectId = projectId
@@ -78,7 +78,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return this.ok(res); return this.ok(res);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新站点监控" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.service,bean.id,"write"); await this.checkOwner(this.service,bean.id,"write");
delete bean.userId; delete bean.userId;
@@ -90,27 +90,27 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
} }
return this.ok(); return this.ok();
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询站点监控详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.service,id,"read"); await this.checkOwner(this.service,id,"read");
return await super.info(id); return await super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除站点监控" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.service,id,"write"); await this.checkOwner(this.service,id,"write");
return await super.delete(id); return await super.delete(id);
} }
@Post('/batchDelete', { description: Constants.per.authOnly }) @Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除站点监控" })
async batchDelete(@Body(ALL) body: any) { async batchDelete(@Body(ALL) body: any) {
const { projectId, userId } = await this.getProjectUserIdWrite() const { projectId, userId } = await this.getProjectUserIdWrite()
await this.service.batchDelete(body.ids,userId,projectId); await this.service.batchDelete(body.ids,userId,projectId);
return this.ok(); return this.ok();
} }
@Post('/check', { description: Constants.per.authOnly }) @Post('/check', { description: Constants.per.authOnly, summary: "检查站点监控" })
async check(@Body('id') id: number) { async check(@Body('id') id: number) {
await this.checkOwner(this.service,id,"read"); await this.checkOwner(this.service,id,"read");
await this.service.check(id, true, 0); await this.service.check(id, true, 0);
@@ -118,14 +118,14 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return this.ok(); return this.ok();
} }
@Post('/checkAll', { description: Constants.per.authOnly }) @Post('/checkAll', { description: Constants.per.authOnly, summary: "检查所有站点监控" })
async checkAll() { async checkAll() {
const { projectId, userId } = await this.getProjectUserIdWrite() const { projectId, userId } = await this.getProjectUserIdWrite()
await this.service.checkAllByUsers(userId,projectId); await this.service.checkAllByUsers(userId,projectId);
return this.ok(); return this.ok();
} }
@Post('/import', { description: Constants.per.authOnly }) @Post('/import', { description: Constants.per.authOnly, summary: "导入站点监控" })
async doImport(@Body(ALL) body: any) { async doImport(@Body(ALL) body: any) {
const { projectId, userId } = await this.getProjectUserIdWrite() const { projectId, userId } = await this.getProjectUserIdWrite()
await this.service.doImport({ await this.service.doImport({
@@ -138,7 +138,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
} }
@Post('/ipCheckChange', { description: Constants.per.authOnly }) @Post('/ipCheckChange', { description: Constants.per.authOnly, summary: "修改IP检查设置" })
async ipCheckChange(@Body(ALL) bean: any) { async ipCheckChange(@Body(ALL) bean: any) {
await this.checkOwner(this.service,bean.id,"read"); await this.checkOwner(this.service,bean.id,"read");
await this.service.ipCheckChange({ await this.service.ipCheckChange({
@@ -148,7 +148,7 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return this.ok(); return this.ok();
} }
@Post('/disabledChange', { description: Constants.per.authOnly }) @Post('/disabledChange', { description: Constants.per.authOnly, summary: "修改禁用状态" })
async disabledChange(@Body(ALL) bean: any) { async disabledChange(@Body(ALL) bean: any) {
await this.checkOwner(this.service,bean.id,"write"); await this.checkOwner(this.service,bean.id,"write");
await this.service.disabledChange({ await this.service.disabledChange({
@@ -158,14 +158,14 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return this.ok(); return this.ok();
} }
@Post("/setting/get", { description: Constants.per.authOnly }) @Post("/setting/get", { description: Constants.per.authOnly, summary: "获取站点监控设置" })
async get() { async get() {
const { userId, projectId } = await this.getProjectUserIdRead() const { userId, projectId } = await this.getProjectUserIdRead()
const setting = await this.service.getSetting(userId, projectId) const setting = await this.service.getSetting(userId, projectId)
return this.ok(setting); return this.ok(setting);
} }
@Post("/setting/save", { description: Constants.per.authOnly }) @Post("/setting/save", { description: Constants.per.authOnly, summary: "保存站点监控设置" })
async save(@Body(ALL) bean: any) { async save(@Body(ALL) bean: any) {
const { userId, projectId} = await this.getProjectUserIdWrite() const { userId, projectId} = await this.getProjectUserIdWrite()
const setting = new UserSiteMonitorSetting(); const setting = new UserSiteMonitorSetting();

View File

@@ -22,7 +22,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询站点IP分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -36,7 +36,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询站点IP列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
body.query = body.query ?? {}; body.query = body.query ?? {};
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
@@ -45,7 +45,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return await super.list(body); return await super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加站点IP" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const { projectId, userId } = await this.getProjectUserIdWrite() const { projectId, userId } = await this.getProjectUserIdWrite()
bean.userId = userId; bean.userId = userId;
@@ -60,7 +60,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return this.ok(res); return this.ok(res);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新站点IP" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.service,bean.id,"write"); await this.checkOwner(this.service,bean.id,"write");
delete bean.userId; delete bean.userId;
@@ -73,13 +73,13 @@ export class SiteInfoController extends CrudController<SiteIpService> {
} }
return this.ok(); return this.ok();
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询站点IP详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.service,id,"read"); await this.checkOwner(this.service,id,"read");
return await super.info(id); return await super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除站点IP" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.service,id,"write"); await this.checkOwner(this.service,id,"write");
const entity = await this.service.info(id); const entity = await this.service.info(id);
@@ -90,7 +90,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
@Post('/check', { description: Constants.per.authOnly }) @Post('/check', { description: Constants.per.authOnly, summary: "检查站点IP" })
async check(@Body('id') id: number) { async check(@Body('id') id: number) {
await this.checkOwner(this.service,id,"read"); await this.checkOwner(this.service,id,"read");
const entity = await this.service.info(id); const entity = await this.service.info(id);
@@ -101,7 +101,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return this.ok(); return this.ok();
} }
@Post('/checkAll', { description: Constants.per.authOnly }) @Post('/checkAll', { description: Constants.per.authOnly, summary: "检查所有站点IP" })
async checkAll(@Body('siteId') siteId: number) { async checkAll(@Body('siteId') siteId: number) {
await this.getProjectUserIdRead() await this.getProjectUserIdRead()
const siteEntity = await this.siteInfoService.info(siteId); const siteEntity = await this.siteInfoService.info(siteId);
@@ -109,7 +109,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return this.ok(); return this.ok();
} }
@Post('/sync', { description: Constants.per.authOnly }) @Post('/sync', { description: Constants.per.authOnly, summary: "同步站点IP" })
async sync(@Body('siteId') siteId: number) { async sync(@Body('siteId') siteId: number) {
await this.getProjectUserIdWrite() await this.getProjectUserIdWrite()
const entity = await this.siteInfoService.info(siteId) const entity = await this.siteInfoService.info(siteId)
@@ -117,7 +117,7 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return this.ok(); return this.ok();
} }
@Post('/import', { description: Constants.per.authOnly }) @Post('/import', { description: Constants.per.authOnly, summary: "导入站点IP" })
async doImport(@Body(ALL) body: any) { async doImport(@Body(ALL) body: any) {
const { userId, projectId } = await this.getProjectUserIdWrite() const { userId, projectId } = await this.getProjectUserIdWrite()
await this.service.doImport({ await this.service.doImport({

View File

@@ -19,7 +19,7 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询开放API密钥分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -30,19 +30,28 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
page: body.page, page: body.page,
sort: body.sort, sort: body.sort,
}); });
this.keySecretDesensitization(res.records);
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) private keySecretDesensitization(list: any[]) {
for (const item of list) {
item.keySecret = item.keySecret?.substring(0, 4) + '*********************************' + item.keySecret?.substring(item.keySecret.length - 4);
}
}
@Post('/list', { description: Constants.per.authOnly, summary: "查询开放API密钥列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
body.query.projectId = projectId; body.query.projectId = projectId;
body.query.userId = userId; body.query.userId = userId;
return await super.list(body); const res = await this.service.list(body);
this.keySecretDesensitization(res);
return this.ok(res);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加开放API密钥" })
async add(@Body(ALL) body: any) { async add(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.projectId = projectId; body.projectId = projectId;
@@ -51,7 +60,7 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
return this.ok(res); return this.ok(res);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新开放API密钥" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId; delete bean.userId;
@@ -59,22 +68,42 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
await this.service.update(bean); await this.service.update(bean);
return this.ok(); return this.ok();
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询开放API密钥详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read"); const info = await this.checkPermission(id);
return await super.info(id); return this.ok(info);
} }
@Post('/delete', { description: Constants.per.authOnly }) private async checkPermission(id: number) {
const info = await this.service.info(id);
if (!info) {
throw new Error('密钥不存在');
}
if (info.scope === 'user'){
await this.checkOwner(this.getService(), id, "write");;
}else{
await this.checkOwner(this.getService(), id, "read");
}
return info
}
@Post('/delete', { description: Constants.per.authOnly, summary: "删除开放API密钥" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return await super.delete(id); return await super.delete(id);
} }
@Post('/getApiToken', { description: Constants.per.authOnly }) @Post('/getApiToken', { description: Constants.per.authOnly, summary: "获取API测试令牌" })
async getApiToken(@Body('id') id: number) { async getApiToken(@Body('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkPermission(id);
const token = await this.service.getApiToken(id); const token = await this.service.getApiToken(id);
return this.ok(token); return this.ok(token);
} }
@Post('/getSecret', { description: Constants.per.authOnly, summary: "获取密钥" })
async getSecret(@Body('id') id: number) {
const info = await this.checkPermission(id);
return this.ok(info.keySecret);
}
} }

View File

@@ -21,7 +21,7 @@ export class AccessController extends CrudController<AccessService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询授权配置分页列表" })
async page(@Body(ALL) body) { async page(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -44,7 +44,7 @@ export class AccessController extends CrudController<AccessService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询授权配置列表" })
async list(@Body(ALL) body) { async list(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -53,7 +53,7 @@ export class AccessController extends CrudController<AccessService> {
return super.list(body); return super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加授权配置" })
async add(@Body(ALL) bean) { async add(@Body(ALL) bean) {
const { projectId, userId } = await this.getProjectUserIdWrite() const { projectId, userId } = await this.getProjectUserIdWrite()
bean.userId = userId; bean.userId = userId;
@@ -61,39 +61,39 @@ export class AccessController extends CrudController<AccessService> {
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新授权配置" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId; delete bean.userId;
delete bean.projectId; delete bean.projectId;
return super.update(bean); return super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询授权配置详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read"); await this.checkOwner(this.getService(), id, "read");
return super.info(id); return super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除授权配置" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return super.delete(id); return super.delete(id);
} }
@Post('/define', { description: Constants.per.authOnly }) @Post('/define', { description: Constants.per.authOnly, summary: "查询授权插件定义" })
async define(@Query('type') type: string) { async define(@Query('type') type: string) {
const access = this.service.getDefineByType(type); const access = this.service.getDefineByType(type);
return this.ok(access); 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 }) { async getSecretPlain(@Body(ALL) body: { id: number; key: string }) {
const {userId, projectId} = await this.checkOwner(this.getService(), body.id, "read"); const {userId, projectId} = await this.checkOwner(this.getService(), body.id, "read");
const value = await this.service.getById(body.id, userId, projectId); const value = await this.service.getById(body.id, userId, projectId);
return this.ok(value[body.key]); return this.ok(value[body.key]);
} }
@Post('/accessTypeDict', { description: Constants.per.authOnly }) @Post('/accessTypeDict', { description: Constants.per.authOnly, summary: "查询授权类型字典" })
async getAccessTypeDict() { async getAccessTypeDict() {
let list: AccessDefine[] = this.service.getDefineList(); let list: AccessDefine[] = this.service.getDefineList();
list = list.sort((a,b) => { list = list.sort((a,b) => {
@@ -110,7 +110,7 @@ export class AccessController extends CrudController<AccessService> {
return this.ok(dict); return this.ok(dict);
} }
@Post('/simpleInfo', { description: Constants.per.authOnly }) @Post('/simpleInfo', { description: Constants.per.authOnly, summary: "查询授权配置简单信息" })
async simpleInfo(@Query('id') id: number) { async simpleInfo(@Query('id') id: number) {
// await this.authService.checkUserIdButAllowAdmin(this.ctx, this.service, id); // await this.authService.checkUserIdButAllowAdmin(this.ctx, this.service, id);
// await this.checkOwner(this.getService(), id, "read",true); // await this.checkOwner(this.getService(), id, "read",true);
@@ -118,7 +118,7 @@ export class AccessController extends CrudController<AccessService> {
return this.ok(res); return this.ok(res);
} }
@Post('/getDictByIds', { description: Constants.per.authOnly }) @Post('/getDictByIds', { description: Constants.per.authOnly, summary: "根据ID列表获取授权配置字典" })
async getDictByIds(@Body('ids') ids: number[]) { async getDictByIds(@Body('ids') ids: number[]) {
const { userId, projectId } = await this.getProjectUserIdRead() const { userId, projectId } = await this.getProjectUserIdRead()
const res = await this.service.getSimpleByIds(ids, userId, projectId); const res = await this.service.getSimpleByIds(ids, userId, projectId);

View File

@@ -21,7 +21,7 @@ export class CertController extends BaseController {
userSettingsService: UserSettingsService; userSettingsService: UserSettingsService;
@Post('/get', { description: Constants.per.authOnly }) @Post('/get', { description: Constants.per.authOnly, summary: "获取证书" })
async getCert(@Query('id') id: number) { async getCert(@Query('id') id: number) {
const {userId} = await this.getProjectUserIdRead() 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) { async readCertDetail(@Body('crt') crt: string) {
if (!crt) { if (!crt) {
throw new Error('crt is required'); throw new Error('crt is required');

View File

@@ -14,13 +14,13 @@ export class DnsProviderController extends BaseController {
@Inject() @Inject()
service: DnsProviderService; service: DnsProviderService;
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询DNS提供商列表" })
async list(@Query(ALL) query: any) { async list(@Query(ALL) query: any) {
const list = this.service.getList(); const list = this.service.getList();
return this.ok(list); return this.ok(list);
} }
@Post('/dnsProviderTypeDict', { description: Constants.per.authOnly }) @Post('/dnsProviderTypeDict', { description: Constants.per.authOnly, summary: "查询DNS提供商类型字典" })
async getDnsProviderTypeDict() { async getDnsProviderTypeDict() {
const list = this.service.getList(); const list = this.service.getList();
const dict = []; const dict = [];

View File

@@ -34,7 +34,7 @@ export class HandleController extends BaseController {
@Inject() @Inject()
notificationService: NotificationService; notificationService: NotificationService;
@Post('/access', { description: Constants.per.authOnly }) @Post('/access', { description: Constants.per.authOnly, summary: "处理授权请求" })
async accessRequest(@Body(ALL) body: AccessRequestHandleReq) { async accessRequest(@Body(ALL) body: AccessRequestHandleReq) {
const {projectId,userId} = await this.getProjectUserIdRead() const {projectId,userId} = await this.getProjectUserIdRead()
let inputAccess = body.input; let inputAccess = body.input;
@@ -64,7 +64,7 @@ export class HandleController extends BaseController {
return this.ok(res); return this.ok(res);
} }
@Post('/notification', { description: Constants.per.authOnly }) @Post('/notification', { description: Constants.per.authOnly, summary: "处理通知请求" })
async notificationRequest(@Body(ALL) body: NotificationRequestHandleReq) { async notificationRequest(@Body(ALL) body: NotificationRequestHandleReq) {
const input = body.input; const input = body.input;
@@ -80,7 +80,7 @@ export class HandleController extends BaseController {
return this.ok(res); return this.ok(res);
} }
@Post('/plugin', { description: Constants.per.authOnly }) @Post('/plugin', { description: Constants.per.authOnly, summary: "处理插件请求" })
async pluginRequest(@Body(ALL) body: PluginRequestHandleReq) { async pluginRequest(@Body(ALL) body: PluginRequestHandleReq) {
const {projectId,userId} = await this.getProjectUserIdRead() const {projectId,userId} = await this.getProjectUserIdRead()
const pluginDefine = pluginRegistry.get(body.typeName); const pluginDefine = pluginRegistry.get(body.typeName);

View File

@@ -41,7 +41,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询流水线执行历史分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
body.query.projectId = projectId body.query.projectId = projectId
@@ -88,7 +88,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询流水线执行历史列表" })
async list(@Body(ALL) body) { async list(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
if (!body){ if (!body){
@@ -151,7 +151,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(listRet); return this.ok(listRet);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加流水线执行历史" })
async add(@Body(ALL) bean: PipelineEntity) { async add(@Body(ALL) bean: PipelineEntity) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
bean.projectId = projectId bean.projectId = projectId
@@ -159,7 +159,7 @@ export class HistoryController extends CrudController<HistoryService> {
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新流水线执行历史" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id,"write",true); await this.checkOwner(this.getService(), bean.id,"write",true);
delete bean.userId; delete bean.userId;
@@ -167,7 +167,7 @@ export class HistoryController extends CrudController<HistoryService> {
return super.update(bean); return super.update(bean);
} }
@Post('/save', { description: Constants.per.authOnly }) @Post('/save', { description: Constants.per.authOnly, summary: "保存流水线执行历史" })
async save(@Body(ALL) bean: HistoryEntity) { async save(@Body(ALL) bean: HistoryEntity) {
const { projectId,userId } = await this.getProjectUserIdWrite() const { projectId,userId } = await this.getProjectUserIdWrite()
bean.userId = userId; bean.userId = userId;
@@ -183,7 +183,7 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(bean.id); return this.ok(bean.id);
} }
@Post('/saveLog', { description: Constants.per.authOnly }) @Post('/saveLog', { description: Constants.per.authOnly, summary: "保存流水线执行日志" })
async saveLog(@Body(ALL) bean: HistoryLogEntity) { async saveLog(@Body(ALL) bean: HistoryLogEntity) {
const { projectId,userId } = await this.getProjectUserIdWrite() const { projectId,userId } = await this.getProjectUserIdWrite()
bean.projectId = projectId; bean.projectId = projectId;
@@ -198,14 +198,14 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(bean.id); return this.ok(bean.id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除流水线执行历史" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"write",true); await this.checkOwner(this.getService(), id,"write",true);
await super.delete(id); await super.delete(id);
return this.ok(); return this.ok();
} }
@Post('/deleteByIds', { description: Constants.per.authOnly }) @Post('/deleteByIds', { description: Constants.per.authOnly, summary: "批量删除流水线执行历史" })
async deleteByIds(@Body(ALL) body: any) { async deleteByIds(@Body(ALL) body: any) {
let {userId} = await this.checkOwner(this.getService(), body.ids,"write",true); let {userId} = await this.checkOwner(this.getService(), body.ids,"write",true);
const isAdmin = await this.authService.isAdmin(this.ctx); const isAdmin = await this.authService.isAdmin(this.ctx);
@@ -214,21 +214,21 @@ export class HistoryController extends CrudController<HistoryService> {
return this.ok(); return this.ok();
} }
@Post('/detail', { description: Constants.per.authOnly }) @Post('/detail', { description: Constants.per.authOnly, summary: "查询流水线执行历史详情" })
async detail(@Query('id') id: number) { async detail(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"read",true); await this.checkOwner(this.getService(), id,"read",true);
const detail = await this.service.detail(id); const detail = await this.service.detail(id);
return this.ok(detail); return this.ok(detail);
} }
@Post('/logs', { description: Constants.per.authOnly }) @Post('/logs', { description: Constants.per.authOnly, summary: "查询流水线执行日志" })
async logs(@Query('id') id: number) { async logs(@Query('id') id: number) {
await this.checkOwner(this.logService, id,"read",true); await this.checkOwner(this.logService, id,"read",true);
const logInfo = await this.logService.info(id); const logInfo = await this.logService.info(id);
return this.ok(logInfo); 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) { async files(@Query('pipelineId') pipelineId: number, @Query('historyId') historyId: number) {
const files = await this.getFiles(historyId, pipelineId); const files = await this.getFiles(historyId, pipelineId);
return this.ok(files); return this.ok(files);
@@ -269,7 +269,7 @@ export class HistoryController extends CrudController<HistoryService> {
return await this.service.getFiles(history); 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) { async download(@Query('pipelineId') pipelineId: number, @Query('historyId') historyId: number, @Query('fileId') fileId: string) {
const files = await this.getFiles(historyId, pipelineId); const files = await this.getFiles(historyId, pipelineId);
const file = files.find(f => f.id === fileId); const file = files.find(f => f.id === fileId);

View File

@@ -22,7 +22,7 @@ export class NotificationController extends CrudController<NotificationService>
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询通知配置分页列表" })
async page(@Body(ALL) body) { async page(@Body(ALL) body) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -40,7 +40,7 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询通知配置列表" })
async list(@Body(ALL) body) { async list(@Body(ALL) body) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -49,7 +49,7 @@ export class NotificationController extends CrudController<NotificationService>
return super.list(body); return super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加通知配置" })
async add(@Body(ALL) bean) { async add(@Body(ALL) bean) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
bean.userId = userId; bean.userId = userId;
@@ -65,7 +65,7 @@ export class NotificationController extends CrudController<NotificationService>
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新通知配置" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id,"write"); await this.checkOwner(this.getService(), bean.id,"write");
const old = await this.service.info(bean.id); const old = await this.service.info(bean.id);
@@ -86,25 +86,25 @@ export class NotificationController extends CrudController<NotificationService>
delete bean.projectId; delete bean.projectId;
return super.update(bean); return super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询通知配置详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"read"); await this.checkOwner(this.getService(), id,"read");
return super.info(id); return super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除通知配置" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"write"); await this.checkOwner(this.getService(), id,"write");
return super.delete(id); return super.delete(id);
} }
@Post('/define', { description: Constants.per.authOnly }) @Post('/define', { description: Constants.per.authOnly, summary: "查询通知插件定义" })
async define(@Query('type') type: string) { async define(@Query('type') type: string) {
const notification = this.service.getDefineByType(type); const notification = this.service.getDefineByType(type);
return this.ok(notification); return this.ok(notification);
} }
@Post('/getTypeDict', { description: Constants.per.authOnly }) @Post('/getTypeDict', { description: Constants.per.authOnly, summary: "查询通知类型字典" })
async getTypeDict() { async getTypeDict() {
const list: any = this.service.getDefineList(); const list: any = this.service.getDefineList();
let dict = []; let dict = [];
@@ -125,7 +125,7 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(dict); return this.ok(dict);
} }
@Post('/simpleInfo', { description: Constants.per.authOnly }) @Post('/simpleInfo', { description: Constants.per.authOnly, summary: "查询通知配置简单信息" })
async simpleInfo(@Query('id') id: number) { async simpleInfo(@Query('id') id: number) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
if (id === 0) { if (id === 0) {
@@ -142,14 +142,14 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(res); return this.ok(res);
} }
@Post('/getDefaultId', { description: Constants.per.authOnly }) @Post('/getDefaultId', { description: Constants.per.authOnly, summary: "查询默认通知配置ID" })
async getDefaultId() { async getDefaultId() {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.getDefault(userId,projectId); const res = await this.service.getDefault(userId,projectId);
return this.ok(res?.id); return this.ok(res?.id);
} }
@Post('/setDefault', { description: Constants.per.authOnly }) @Post('/setDefault', { description: Constants.per.authOnly, summary: "设置默认通知配置" })
async setDefault(@Query('id') id: number) { async setDefault(@Query('id') id: number) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
await this.checkOwner(this.getService(), id,"write"); await this.checkOwner(this.getService(), id,"write");
@@ -157,14 +157,14 @@ export class NotificationController extends CrudController<NotificationService>
return this.ok(res); return this.ok(res);
} }
@Post('/getOrCreateDefault', { description: Constants.per.authOnly }) @Post('/getOrCreateDefault', { description: Constants.per.authOnly, summary: "获取或创建默认通知配置" })
async getOrCreateDefault(@Body('email') email: string) { async getOrCreateDefault(@Body('email') email: string) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.getOrCreateDefault(email, userId,projectId); const res = await this.service.getOrCreateDefault(email, userId,projectId);
return this.ok(res); return this.ok(res);
} }
@Post('/options', { description: Constants.per.authOnly }) @Post('/options', { description: Constants.per.authOnly, summary: "查询通知配置选项" })
async options() { async options() {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const res = await this.service.list({ const res = await this.service.list({

View File

@@ -1,12 +1,108 @@
import { Constants, CrudController, SysSettingsService } from '@certd/lib-server'; import { Constants, CrudController, SysSettingsService } from '@certd/lib-server';
import { isPlus } from '@certd/plus-core'; import { isPlus } from '@certd/plus-core';
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/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 { SiteInfoService } from '../../../modules/monitor/index.js';
import { PipelineEntity } from '../../../modules/pipeline/entity/pipeline.js';
import { HistoryService } from '../../../modules/pipeline/service/history-service.js'; import { HistoryService } from '../../../modules/pipeline/service/history-service.js';
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js'; import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
import { AuthService } from '../../../modules/sys/authority/service/auth-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; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询流水线分页列表" })
async page(@Body(ALL) body) { async page(@Body(ALL) body) {
const isAdmin = await this.authService.isAdmin(this.ctx); const isAdmin = await this.authService.isAdmin(this.ctx);
const publicSettings = await this.sysSettingsService.getPublicSettings(); const publicSettings = await this.sysSettingsService.getPublicSettings();
@@ -79,7 +175,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok(pageRet); return this.ok(pageRet);
} }
@Post('/getSimpleByIds', { description: Constants.per.authOnly }) @Post('/getSimpleByIds', { description: Constants.per.authOnly, summary: "根据ID列表获取流水线简单信息" })
async getSimpleById(@Body(ALL) body) { async getSimpleById(@Body(ALL) body) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
const ret = await this.getService().getSimplePipelines(body.ids, userId, projectId); 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: '新增/更新流水线' }) @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() const { userId ,projectId} = await this.getProjectUserIdWrite()
if (bean.id > 0) { if (bean.id > 0) {
const {userId,projectId} = await this.checkOwner(this.getService(), bean.id,"write",true); 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 delete bean.validTime
} }
const { version } = await this.service.save(bean); const { version } = await this.service.save(bean as any);
//是否增加证书监控 //是否增加证书监控
if (bean.addToMonitorEnabled && bean.addToMonitorDomains) { if (bean.addToMonitorEnabled && bean.addToMonitorDomains) {
const sysPublicSettings = await this.sysSettingsService.getPublicSettings(); const sysPublicSettings = await this.sysSettingsService.getPublicSettings();
@@ -136,14 +232,14 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({ id: bean.id, version: version }); 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) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"write",true); await this.checkOwner(this.getService(), id,"write",true);
await this.service.delete(id); await this.service.delete(id);
return this.ok({}); return this.ok({});
} }
@Post('/disabled', { description: Constants.per.authOnly }) @Post('/disabled', { description: Constants.per.authOnly, summary: "禁用流水线" })
async disabled(@Body(ALL) bean) { async disabled(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id,"write",true); await this.checkOwner(this.getService(), bean.id,"write",true);
delete bean.userId; delete bean.userId;
@@ -152,28 +248,28 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({}); return this.ok({});
} }
@Post('/detail', { description: Constants.per.authOnly }) @Post('/detail', { description: Constants.per.authOnly, summary: "查询流水线详情" })
async detail(@Query('id') id: number) { async detail(@Query('id') id: number) {
await this.checkOwner(this.getService(), id,"read",true); await this.checkOwner(this.getService(), id,"read",true);
const detail = await this.service.detail(id); const detail = await this.service.detail(id);
return this.ok(detail); 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) { async trigger(@Query('id') id: number, @Query('stepId') stepId?: string) {
await this.checkOwner(this.getService(), id,"write",true); await this.checkOwner(this.getService(), id,"write",true);
await this.service.trigger(id, stepId, true); await this.service.trigger(id, stepId, true);
return this.ok({}); return this.ok({});
} }
@Post('/cancel', { description: Constants.per.authOnly }) @Post('/cancel', { description: Constants.per.authOnly, summary: "取消流水线执行" })
async cancel(@Query('historyId') historyId: number) { async cancel(@Query('historyId') historyId: number) {
await this.checkOwner(this.historyService, historyId,"write",true); await this.checkOwner(this.historyService, historyId,"write",true);
await this.service.cancel(historyId); await this.service.cancel(historyId);
return this.ok({}); return this.ok({});
} }
@Post('/count', { description: Constants.per.authOnly }) @Post('/count', { description: Constants.per.authOnly, summary: "查询流水线数量" })
async count() { async count() {
const { userId } = await this.getProjectUserIdRead() const { userId } = await this.getProjectUserIdRead()
const count = await this.service.count({ userId: userId }); const count = await this.service.count({ userId: userId });
@@ -191,7 +287,7 @@ export class PipelineController extends CrudController<PipelineService> {
return await callback({userId}); return await callback({userId});
} }
@Post('/batchDelete', { description: Constants.per.authOnly }) @Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除流水线" })
async batchDelete(@Body('ids') ids: number[]) { async batchDelete(@Body('ids') ids: number[]) {
// let { projectId ,userId} = await this.getProjectUserIdWrite() // let { projectId ,userId} = await this.getProjectUserIdWrite()
// if(projectId){ // 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) { async batchUpdateGroup(@Body('ids') ids: number[], @Body('groupId') groupId: number) {
// let { projectId ,userId} = await this.getProjectUserIdWrite() // let { projectId ,userId} = await this.getProjectUserIdWrite()
// if(projectId){ // 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) { async batchUpdateTrigger(@Body('ids') ids: number[], @Body('trigger') trigger: any) {
// let { projectId ,userId} = await this.getProjectUserIdWrite() // let { projectId ,userId} = await this.getProjectUserIdWrite()
// if(projectId){ // if(projectId){
@@ -245,7 +341,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({}); 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) { async batchUpdateNotification(@Body('ids') ids: number[], @Body('notification') notification: any) {
// const isAdmin = await this.authService.isAdmin(this.ctx); // const isAdmin = await this.authService.isAdmin(this.ctx);
// const userId = isAdmin ? undefined : this.getUserId(); // const userId = isAdmin ? undefined : this.getUserId();
@@ -256,7 +352,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({}); 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) { async batchRerun(@Body('ids') ids: number[], @Body('force') force: boolean) {
await this.checkPermissionCall(async ({userId,projectId})=>{ await this.checkPermissionCall(async ({userId,projectId})=>{
await this.service.batchRerun(ids, force,userId,projectId); await this.service.batchRerun(ids, force,userId,projectId);
@@ -264,7 +360,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({}); 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) { async batchTransfer(@Body('ids') ids: number[], @Body('toProjectId') toProjectId: number) {
await this.checkPermissionCall(async ({})=>{ await this.checkPermissionCall(async ({})=>{
await this.service.batchTransfer(ids, toProjectId); await this.service.batchTransfer(ids, toProjectId);
@@ -272,7 +368,7 @@ export class PipelineController extends CrudController<PipelineService> {
return this.ok({}); return this.ok({});
} }
@Post('/refreshWebhookKey', { description: Constants.per.authOnly }) @Post('/refreshWebhookKey', { description: Constants.per.authOnly, summary: "刷新Webhook密钥" })
async refreshWebhookKey(@Body('id') id: number) { async refreshWebhookKey(@Body('id') id: number) {
await this.checkOwner(this.getService(), id,"write",true); await this.checkOwner(this.getService(), id,"write",true);
const res = await this.service.refreshWebhookKey(id); const res = await this.service.refreshWebhookKey(id);

View File

@@ -20,7 +20,7 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return this.service; return this.service;
} }
@Post('/page', { description: Constants.per.authOnly }) @Post('/page', { description: Constants.per.authOnly, summary: "查询流水线分组分页列表" })
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -38,7 +38,7 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询流水线分组列表" })
async list(@Body(ALL) body: any) { async list(@Body(ALL) body: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -47,7 +47,7 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return await super.list(body); return await super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加流水线分组" })
async add(@Body(ALL) bean: any) { async add(@Body(ALL) bean: any) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
bean.userId = userId; bean.userId = userId;
@@ -55,26 +55,26 @@ export class PipelineGroupController extends CrudController<PipelineGroupService
return await super.add(bean); return await super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新流水线分组" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId; delete bean.userId;
delete bean.projectId; delete bean.projectId;
return await super.update(bean); return await super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询流水线分组详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read"); await this.checkOwner(this.getService(), id, "read");
return await super.info(id); return await super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除流水线分组" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return await super.delete(id); return await super.delete(id);
} }
@Post('/all', { description: Constants.per.authOnly }) @Post('/all', { description: Constants.per.authOnly, summary: "查询所有流水线分组" })
async all() { async all() {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const list: any = await this.service.find({ const list: any = await this.service.find({

View File

@@ -18,19 +18,19 @@ export class PluginController extends BaseController {
@Inject() @Inject()
pluginConfigService: PluginConfigService; pluginConfigService: PluginConfigService;
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询插件列表" })
async list(@Query(ALL) query: any) { async list(@Query(ALL) query: any) {
const list = await this.service.getEnabledBuiltInList(); const list = await this.service.getEnabledBuiltInList();
return this.ok(list); return this.ok(list);
} }
@Post('/groups', { description: Constants.per.authOnly }) @Post('/groups', { description: Constants.per.authOnly, summary: "查询插件分组" })
async groups(@Query(ALL) query: any) { async groups(@Query(ALL) query: any) {
const group = await this.service.getEnabledBuildInGroup(); const group = await this.service.getEnabledBuildInGroup();
return this.ok(group); return this.ok(group);
} }
@Post('/groupsList', { description: Constants.per.authOnly }) @Post('/groupsList', { description: Constants.per.authOnly, summary: "查询插件分组列表" })
async groupsList(@Query(ALL) query: any) { async groupsList(@Query(ALL) query: any) {
const groups = pluginGroups const groups = pluginGroups
const groupsList:any = [] const groupsList:any = []
@@ -44,13 +44,13 @@ export class PluginController extends BaseController {
return this.ok(groupsList); return this.ok(groupsList);
} }
@Post('/getDefineByType', { description: Constants.per.authOnly }) @Post('/getDefineByType', { description: Constants.per.authOnly, summary: "根据类型获取插件定义" })
async getDefineByType(@Body('type') type: string) { async getDefineByType(@Body('type') type: string) {
const define = await this.service.getDefineByType(type); const define = await this.service.getDefineByType(type);
return this.ok(define); 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 }) { async config(@Body(ALL) body: { id?: number; name?: string; type: string }) {
const config = await this.pluginConfigService.getPluginConfig(body); const config = await this.pluginConfigService.getPluginConfig(body);
return this.ok(config); return this.ok(config);

View File

@@ -22,7 +22,7 @@ export class SubDomainController extends CrudController<SubDomainService> {
return this.service; return this.service;
} }
@Post('/parseDomain', { description: Constants.per.authOnly }) @Post('/parseDomain', { description: Constants.per.authOnly, summary: "解析域名" })
async parseDomain(@Body("fullDomain") fullDomain:string) { async parseDomain(@Body("fullDomain") fullDomain:string) {
const {projectId,userId} = await this.getProjectUserIdRead(); const {projectId,userId} = await this.getProjectUserIdRead();
const taskService = this.taskServiceBuilder.create({ userId: userId, projectId: projectId }); 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) { async page(@Body(ALL) body) {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -51,7 +51,7 @@ export class SubDomainController extends CrudController<SubDomainService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询子域名列表" })
async list(@Body(ALL) body) { async list(@Body(ALL) body) {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -60,7 +60,7 @@ export class SubDomainController extends CrudController<SubDomainService> {
return super.list(body); return super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加子域名" })
async add(@Body(ALL) bean) { async add(@Body(ALL) bean) {
const {userId,projectId} = await this.getProjectUserIdRead(); const {userId,projectId} = await this.getProjectUserIdRead();
bean.userId = userId; bean.userId = userId;
@@ -68,26 +68,26 @@ export class SubDomainController extends CrudController<SubDomainService> {
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新子域名" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.getService(), bean.id, "write"); await this.checkOwner(this.getService(), bean.id, "write");
delete bean.userId; delete bean.userId;
delete bean.projectId; delete bean.projectId;
return super.update(bean); return super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询子域名详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "read"); await this.checkOwner(this.getService(), id, "read");
return super.info(id); return super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除子域名" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
await this.checkOwner(this.getService(), id, "write"); await this.checkOwner(this.getService(), id, "write");
return super.delete(id); return super.delete(id);
} }
@Post('/batchDelete', { description: Constants.per.authOnly }) @Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除子域名" })
async batchDelete(@Body('ids') ids: number[]) { async batchDelete(@Body('ids') ids: number[]) {
const {userId,projectId} = await this.getProjectUserIdWrite(); const {userId,projectId} = await this.getProjectUserIdWrite();
await this.service.batchDelete(ids, userId, projectId); await this.service.batchDelete(ids, userId, projectId);

View File

@@ -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) { async page(@Body(ALL) body) {
body.query = body.query ?? {}; body.query = body.query ?? {};
@@ -39,7 +39,7 @@ export class TemplateController extends CrudController<TemplateService> {
return this.ok(res); return this.ok(res);
} }
@Post('/list', { description: Constants.per.authOnly }) @Post('/list', { description: Constants.per.authOnly, summary: "查询流水线模版列表" })
async list(@Body(ALL) body) { async list(@Body(ALL) body) {
body.query = body.query ?? {}; body.query = body.query ?? {};
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
@@ -48,7 +48,7 @@ export class TemplateController extends CrudController<TemplateService> {
return super.list(body); return super.list(body);
} }
@Post('/add', { description: Constants.per.authOnly }) @Post('/add', { description: Constants.per.authOnly, summary: "添加流水线模版" })
async add(@Body(ALL) bean) { async add(@Body(ALL) bean) {
const { projectId, userId } = await this.getProjectUserIdRead() const { projectId, userId } = await this.getProjectUserIdRead()
bean.userId = userId; bean.userId = userId;
@@ -57,40 +57,40 @@ export class TemplateController extends CrudController<TemplateService> {
return super.add(bean); return super.add(bean);
} }
@Post('/update', { description: Constants.per.authOnly }) @Post('/update', { description: Constants.per.authOnly, summary: "更新流水线模版" })
async update(@Body(ALL) bean) { async update(@Body(ALL) bean) {
await this.checkOwner(this.service, bean.id, "write"); await this.checkOwner(this.service, bean.id, "write");
delete bean.userId; delete bean.userId;
delete bean.projectId; delete bean.projectId;
return super.update(bean); return super.update(bean);
} }
@Post('/info', { description: Constants.per.authOnly }) @Post('/info', { description: Constants.per.authOnly, summary: "查询流水线模版详情" })
async info(@Query('id') id: number) { async info(@Query('id') id: number) {
await this.checkOwner(this.service, id, "read"); await this.checkOwner(this.service, id, "read");
return super.info(id); return super.info(id);
} }
@Post('/delete', { description: Constants.per.authOnly }) @Post('/delete', { description: Constants.per.authOnly, summary: "删除流水线模版" })
async delete(@Query('id') id: number) { async delete(@Query('id') id: number) {
const { userId ,projectId } = await this.getProjectUserIdWrite() const { userId ,projectId } = await this.getProjectUserIdWrite()
await this.service.batchDelete([id], userId,projectId); await this.service.batchDelete([id], userId,projectId);
return this.ok({}); return this.ok({});
} }
@Post('/batchDelete', { description: Constants.per.authOnly }) @Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除流水线模版" })
async batchDelete(@Body('ids') ids: number[]) { async batchDelete(@Body('ids') ids: number[]) {
const { userId ,projectId } = await this.getProjectUserIdWrite() const { userId ,projectId } = await this.getProjectUserIdWrite()
await this.service.batchDelete(ids, userId,projectId); await this.service.batchDelete(ids, userId,projectId);
return this.ok({}); return this.ok({});
} }
@Post('/detail', { description: Constants.per.authOnly }) @Post('/detail', { description: Constants.per.authOnly, summary: "查询流水线模版详情" })
async detail(@Query('id') id: number) { async detail(@Query('id') id: number) {
const { userId ,projectId } = await this.getProjectUserIdRead() const { userId ,projectId } = await this.getProjectUserIdRead()
const detail = await this.service.detail(id, userId,projectId); const detail = await this.service.detail(id, userId,projectId);
return this.ok(detail); return this.ok(detail);
} }
@Post('/createPipelineByTemplate', { description: Constants.per.authOnly }) @Post('/createPipelineByTemplate', { description: Constants.per.authOnly, summary: "根据模版创建流水线" })
async createPipelineByTemplate(@Body(ALL) body: any) { async createPipelineByTemplate(@Body(ALL) body: any) {
const { userId ,projectId } = await this.getProjectUserIdWrite() const { userId ,projectId } = await this.getProjectUserIdWrite()
body.userId = userId; body.userId = userId;

View File

@@ -93,7 +93,7 @@ export class AuthorityMiddleware implements IWebMiddleware {
await next(); await next();
return; return;
} else if (openKey.scope === 'open') { } else if (openKey.scope === 'open') {
return this.notAuth(ctx); return this.notAuth(ctx, 'open key scope errorneed user scope');
} }
} }
@@ -113,9 +113,13 @@ export class AuthorityMiddleware implements IWebMiddleware {
}; };
} }
private notAuth(ctx: IMidwayKoaContext) { private notAuth(ctx: IMidwayKoaContext, message?: string) {
ctx.status = 401; ctx.status = 401;
ctx.body = Constants.res.auth; ctx.body = Constants.res.auth;
if (message) {
// @ts-ignore
ctx.body.message =message;
}
return; return;
} }

3
pnpm-lock.yaml generated
View File

@@ -803,6 +803,9 @@ importers:
'@midwayjs/logger': '@midwayjs/logger':
specifier: 3.4.2 specifier: 3.4.2
version: 3.4.2 version: 3.4.2
'@midwayjs/swagger':
specifier: 3.20.11
version: 3.20.11
'@midwayjs/typeorm': '@midwayjs/typeorm':
specifier: 3.20.11 specifier: 3.20.11
version: 3.20.11 version: 3.20.11