mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
perf: EAB授权支持绑定邮箱,支持公共EAB设置
This commit is contained in:
@@ -23,7 +23,7 @@ export class PluginEntity {
|
||||
@Column({ comment: '配置', length: 40960 })
|
||||
setting: string;
|
||||
|
||||
@Column({ comment: '系统配置', length: 40960 })
|
||||
@Column({ name: 'sys_setting', comment: '系统配置', length: 40960 })
|
||||
sysSetting: string;
|
||||
|
||||
@Column({ comment: '脚本', length: 40960 })
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { IPluginConfigService, PluginConfig } from '@certd/pipeline';
|
||||
import { PluginConfigService } from './plugin-config-service.js';
|
||||
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class PluginConfigGetter implements IPluginConfigService {
|
||||
@Inject()
|
||||
pluginConfigService: PluginConfigService;
|
||||
|
||||
async getPluginConfig(pluginName: string): Promise<PluginConfig> {
|
||||
const res = await this.pluginConfigService.getPluginConfig({
|
||||
name: pluginName,
|
||||
type: 'builtIn',
|
||||
});
|
||||
return {
|
||||
name: res.name,
|
||||
disabled: res.disabled,
|
||||
sysSetting: res.sysSetting,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { PluginService } from './plugin-service.js';
|
||||
|
||||
export type PluginConfig = {
|
||||
name: string;
|
||||
disabled: boolean;
|
||||
sysSetting: {
|
||||
input?: Record<string, any>;
|
||||
};
|
||||
};
|
||||
|
||||
export type CommPluginConfig = {
|
||||
CertApply?: PluginConfig;
|
||||
};
|
||||
|
||||
export type PluginFindReq = {
|
||||
id?: number;
|
||||
name?: string;
|
||||
type: string;
|
||||
};
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class PluginConfigService {
|
||||
@Inject()
|
||||
pluginService: PluginService;
|
||||
|
||||
async getCommPluginConfig() {
|
||||
const configs: CommPluginConfig = {};
|
||||
|
||||
configs.CertApply = await this.getPluginConfig({
|
||||
name: 'CertApply',
|
||||
type: 'builtIn',
|
||||
});
|
||||
return configs;
|
||||
}
|
||||
|
||||
async saveCommPluginConfig(body: CommPluginConfig) {
|
||||
const certApplyConfig = body.CertApply;
|
||||
const CertApply = await this.pluginService.getRepository().findOne({
|
||||
where: { name: 'CertApply' },
|
||||
});
|
||||
if (!CertApply) {
|
||||
await this.pluginService.add({
|
||||
name: 'CertApply',
|
||||
sysSetting: JSON.stringify(certApplyConfig),
|
||||
type: 'builtIn',
|
||||
disabled: false,
|
||||
});
|
||||
} else {
|
||||
await this.pluginService.getRepository().update({ name: 'CertApply' }, { sysSetting: JSON.stringify(certApplyConfig) });
|
||||
}
|
||||
}
|
||||
|
||||
async get(req: PluginFindReq) {
|
||||
if (!req.name && !req.id) {
|
||||
throw new Error('plugin s name or id is required');
|
||||
}
|
||||
return await this.pluginService.getRepository().findOne({
|
||||
where: {
|
||||
id: req.id,
|
||||
name: req.name,
|
||||
type: req.type,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getPluginConfig(req: PluginFindReq) {
|
||||
const plugin = await this.get(req);
|
||||
let sysSetting: any = {};
|
||||
if (plugin && plugin.sysSetting) {
|
||||
sysSetting = JSON.parse(plugin.sysSetting);
|
||||
}
|
||||
return {
|
||||
name: plugin.name,
|
||||
disabled: plugin.disabled,
|
||||
sysSetting,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user