mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
perf: 部署插件支持宝塔、易盾云等
This commit is contained in:
@@ -49,7 +49,7 @@ export class PermissionController extends CrudController<PermissionService> {
|
||||
@Post('/delete', { summary: 'sys:auth:per:remove' })
|
||||
async delete(
|
||||
@Query('id')
|
||||
id
|
||||
id : number
|
||||
) {
|
||||
return await super.delete(id);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
import {
|
||||
ALL,
|
||||
Body,
|
||||
Controller,
|
||||
Inject,
|
||||
Post,
|
||||
Provide,
|
||||
Query,
|
||||
} from '@midwayjs/core';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { CrudController } from '../../../basic/crud-controller.js';
|
||||
import { RoleService } from '../service/role-service.js';
|
||||
|
||||
@@ -55,7 +47,7 @@ export class RoleController extends CrudController<RoleService> {
|
||||
@Post('/delete', { summary: 'sys:auth:role:remove' })
|
||||
async delete(
|
||||
@Query('id')
|
||||
id
|
||||
id: number
|
||||
) {
|
||||
return await super.delete(id);
|
||||
}
|
||||
@@ -63,7 +55,7 @@ export class RoleController extends CrudController<RoleService> {
|
||||
@Post('/getPermissionTree', { summary: 'sys:auth:role:view' })
|
||||
async getPermissionTree(
|
||||
@Query('id')
|
||||
id
|
||||
id: number
|
||||
) {
|
||||
const ret = await this.service.getPermissionTreeByRoleId(id);
|
||||
return this.ok(ret);
|
||||
@@ -72,7 +64,7 @@ export class RoleController extends CrudController<RoleService> {
|
||||
@Post('/getPermissionIds', { summary: 'sys:auth:role:view' })
|
||||
async getPermissionIds(
|
||||
@Query('id')
|
||||
id
|
||||
id: number
|
||||
) {
|
||||
const ret = await this.service.getPermissionIdsByRoleId(id);
|
||||
return this.ok(ret);
|
||||
|
||||
@@ -73,7 +73,7 @@ export class UserController extends CrudController<UserService> {
|
||||
@Post('/delete', { summary: 'sys:auth:user:remove' })
|
||||
async delete(
|
||||
@Query('id')
|
||||
id
|
||||
id : number
|
||||
) {
|
||||
return await super.delete(id);
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ export class UserSettingsController extends CrudController<UserSettingsService>
|
||||
return super.update(bean);
|
||||
}
|
||||
@Post('/info', { summary: Constants.per.authOnly })
|
||||
async info(@Query('id') id) {
|
||||
async info(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id) {
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@@ -41,19 +41,19 @@ export class AccessController extends CrudController<AccessService> {
|
||||
return super.update(bean);
|
||||
}
|
||||
@Post('/info', { summary: Constants.per.authOnly })
|
||||
async info(@Query('id') id) {
|
||||
async info(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id) {
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@Post('/define', { summary: Constants.per.authOnly })
|
||||
async define(@Query('type') type) {
|
||||
async define(@Query('type') type:string) {
|
||||
const access = this.service.getDefineByType(type);
|
||||
return this.ok(access);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export class DnsProviderController extends BaseController {
|
||||
service: DnsProviderService;
|
||||
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
async list(@Query(ALL) query) {
|
||||
async list(@Query(ALL) query:any) {
|
||||
query.userId = this.ctx.user.id;
|
||||
const list = this.service.getList();
|
||||
return this.ok(list);
|
||||
|
||||
@@ -99,14 +99,14 @@ export class HistoryController extends CrudController<HistoryService> {
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id) {
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.getService(), id);
|
||||
await super.delete(id);
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@Post('/deleteByIds', { summary: Constants.per.authOnly })
|
||||
async deleteByIds(@Body(ALL) body) {
|
||||
async deleteByIds(@Body(ALL) body: any) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.getService(), body.ids);
|
||||
const isAdmin = await this.authService.isAdmin(this.ctx);
|
||||
const userId = isAdmin ? null : this.ctx.user.id;
|
||||
@@ -115,21 +115,21 @@ export class HistoryController extends CrudController<HistoryService> {
|
||||
}
|
||||
|
||||
@Post('/detail', { summary: Constants.per.authOnly })
|
||||
async detail(@Query('id') id) {
|
||||
async detail(@Query('id') id: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.getService(), id);
|
||||
const detail = await this.service.detail(id);
|
||||
return this.ok(detail);
|
||||
}
|
||||
|
||||
@Post('/logs', { summary: Constants.per.authOnly })
|
||||
async logs(@Query('id') id) {
|
||||
async logs(@Query('id') id: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.logService, id);
|
||||
const logInfo = await this.logService.info(id);
|
||||
return this.ok(logInfo);
|
||||
}
|
||||
|
||||
@Post('/files', { summary: Constants.per.authOnly })
|
||||
async files(@Query('pipelineId') pipelineId, @Query('historyId') historyId) {
|
||||
async files(@Query('pipelineId') pipelineId: number, @Query('historyId') historyId: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.service, historyId);
|
||||
const files = await this.getFiles(historyId, pipelineId);
|
||||
return this.ok(files);
|
||||
@@ -153,7 +153,7 @@ export class HistoryController extends CrudController<HistoryService> {
|
||||
}
|
||||
|
||||
@Get('/download', { summary: Constants.per.authOnly })
|
||||
async download(@Query('pipelineId') pipelineId, @Query('historyId') historyId, @Query('fileId') fileId) {
|
||||
async download(@Query('pipelineId') pipelineId: number, @Query('historyId') historyId: number, @Query('fileId') fileId: string) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.service, historyId);
|
||||
const files = await this.getFiles(historyId, pipelineId);
|
||||
const file = files.find(f => f.id === fileId);
|
||||
|
||||
@@ -73,28 +73,28 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id) {
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.getService(), id);
|
||||
await this.service.delete(id);
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post('/detail', { summary: Constants.per.authOnly })
|
||||
async detail(@Query('id') id) {
|
||||
async detail(@Query('id') id: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.getService(), id);
|
||||
const detail = await this.service.detail(id);
|
||||
return this.ok(detail);
|
||||
}
|
||||
|
||||
@Post('/trigger', { summary: Constants.per.authOnly })
|
||||
async trigger(@Query('id') id) {
|
||||
async trigger(@Query('id') id: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.getService(), id);
|
||||
await this.service.trigger(id);
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post('/cancel', { summary: Constants.per.authOnly })
|
||||
async cancel(@Query('historyId') historyId) {
|
||||
async cancel(@Query('historyId') historyId: number) {
|
||||
await this.authService.checkEntityUserId(this.ctx, this.historyService, historyId);
|
||||
await this.service.cancel(historyId);
|
||||
return this.ok({});
|
||||
|
||||
@@ -13,14 +13,14 @@ export class PluginController extends BaseController {
|
||||
service: PluginService;
|
||||
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
async list(@Query(ALL) query) {
|
||||
async list(@Query(ALL) query: any) {
|
||||
query.userId = this.ctx.user.id;
|
||||
const list = this.service.getList();
|
||||
return this.ok(list);
|
||||
}
|
||||
|
||||
@Post('/groups', { summary: Constants.per.authOnly })
|
||||
async groups(@Query(ALL) query) {
|
||||
async groups(@Query(ALL) query: any) {
|
||||
query.userId = this.ctx.user.id;
|
||||
const group = this.service.getGroups();
|
||||
return this.ok(group);
|
||||
|
||||
@@ -50,7 +50,7 @@ export class AccessService extends BaseService<AccessEntity> implements IAccessS
|
||||
const json = JSON.parse(setting);
|
||||
let oldSetting = {};
|
||||
let encryptSetting = {};
|
||||
const firstEncrypt = !oldSettingEntity.encryptSetting || oldSettingEntity.encryptSetting === '{}';
|
||||
const firstEncrypt = !oldSettingEntity || !oldSettingEntity.encryptSetting || oldSettingEntity.encryptSetting === '{}';
|
||||
if (oldSettingEntity) {
|
||||
oldSetting = JSON.parse(oldSettingEntity.setting || '{}');
|
||||
encryptSetting = JSON.parse(oldSettingEntity.encryptSetting || '{}');
|
||||
|
||||
@@ -44,7 +44,7 @@ export class HistoryService extends BaseService<HistoryEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
async detail(historyId: string) {
|
||||
async detail(historyId: number) {
|
||||
const entity = await this.info(historyId);
|
||||
const log = await this.logService.info(historyId);
|
||||
return new HistoryDetail(entity, log);
|
||||
|
||||
@@ -45,13 +45,13 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
|
||||
return super.update(bean);
|
||||
}
|
||||
@Post('/info', { summary: 'sys:settings:view' })
|
||||
async info(@Query('id') id) {
|
||||
async info(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: 'sys:settings:edit' })
|
||||
async delete(@Query('id') id) {
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user