mirror of
https://github.com/certd/certd.git
synced 2026-05-16 05:07:32 +08:00
chore: plugin管理
This commit is contained in:
@@ -12,6 +12,10 @@ export class AccessController extends CrudController<AccessService> {
|
||||
@Inject()
|
||||
service: AccessService;
|
||||
|
||||
userId() {
|
||||
return this.getUserId();
|
||||
}
|
||||
|
||||
getService(): AccessService {
|
||||
return this.service;
|
||||
}
|
||||
@@ -19,36 +23,36 @@ export class AccessController extends CrudController<AccessService> {
|
||||
@Post('/page', { summary: Constants.per.authOnly })
|
||||
async page(@Body(ALL) body) {
|
||||
body.query = body.query ?? {};
|
||||
body.query.userId = this.getUserId();
|
||||
body.query.userId = this.userId();
|
||||
return await super.page(body);
|
||||
}
|
||||
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
async list(@Body(ALL) body) {
|
||||
body.userId = this.getUserId();
|
||||
body.userId = this.userId();
|
||||
return super.list(body);
|
||||
}
|
||||
|
||||
@Post('/add', { summary: Constants.per.authOnly })
|
||||
async add(@Body(ALL) bean) {
|
||||
bean.userId = this.getUserId();
|
||||
bean.userId = this.userId();
|
||||
return super.add(bean);
|
||||
}
|
||||
|
||||
@Post('/update', { summary: Constants.per.authOnly })
|
||||
async update(@Body(ALL) bean) {
|
||||
await this.service.checkUserId(bean.id, this.getUserId());
|
||||
await this.service.checkUserId(bean.id, this.userId());
|
||||
return super.update(bean);
|
||||
}
|
||||
@Post('/info', { summary: Constants.per.authOnly })
|
||||
async info(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.getUserId());
|
||||
await this.service.checkUserId(id, this.userId());
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.getUserId());
|
||||
await this.service.checkUserId(id, this.userId());
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { ALL, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { BaseController } from '@certd/lib-server';
|
||||
import { PluginService } from '../service/plugin-service.js';
|
||||
import { Constants } from '@certd/lib-server';
|
||||
|
||||
/**
|
||||
* 插件
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/pi/plugin')
|
||||
export class PluginController extends BaseController {
|
||||
@Inject()
|
||||
service: PluginService;
|
||||
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
async list(@Query(ALL) query: any) {
|
||||
query.userId = this.getUserId();
|
||||
const list = this.service.getList();
|
||||
return this.ok(list);
|
||||
}
|
||||
|
||||
@Post('/groups', { summary: Constants.per.authOnly })
|
||||
async groups(@Query(ALL) query: any) {
|
||||
query.userId = this.getUserId();
|
||||
const group = this.service.getGroups();
|
||||
return this.ok(group);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import { UserService } from '../../sys/authority/service/user-service.js';
|
||||
import { AccessGetter } from './access-getter.js';
|
||||
import { CnameRecordService } from '../../cname/service/cname-record-service.js';
|
||||
import { CnameProxyService } from './cname-proxy-service.js';
|
||||
import { PluginConfigService } from './plugin-config-service.js';
|
||||
|
||||
const runningTasks: Map<string | number, Executor> = new Map();
|
||||
const freeCount = 10;
|
||||
@@ -45,6 +46,9 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
@Inject()
|
||||
historyLogService: HistoryLogService;
|
||||
|
||||
@Inject()
|
||||
pluginConfigService: PluginConfigService;
|
||||
|
||||
@Inject()
|
||||
userService: UserService;
|
||||
|
||||
@@ -356,6 +360,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
onChanged,
|
||||
accessService: accessGetter,
|
||||
cnameProxyService,
|
||||
pluginConfigService: this.pluginConfigService,
|
||||
storage: new DbStorage(userId, this.storageService),
|
||||
emailService: this.emailService,
|
||||
fileRootDir: this.certdConfig.fileRootDir,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { IPluginConfigService } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 授权
|
||||
*/
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class PluginConfigService implements IPluginConfigService {
|
||||
getPluginConfig(pluginName: string) {
|
||||
return Promise.resolve({});
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { pluginGroups, pluginRegistry } from '@certd/pipeline';
|
||||
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class PluginService {
|
||||
export class BuiltInPluginService {
|
||||
getList() {
|
||||
const collection = pluginRegistry.storage;
|
||||
const list = [];
|
||||
|
||||
Reference in New Issue
Block a user