wangrong
2022-07-08 7e9badac4f3df3650e72bd419f9cdaa485b054d6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Inject, Provide } from '@midwayjs/decorator';
import { BaseService, ICoolCache, CoolPlugin } from '@cool-midway/core';
 
/**
 * 插件
 */
@Provide()
export class BasePluginInfoService extends BaseService {
  @Inject('cool:coolPlugin')
  coolPlugin: CoolPlugin;
 
  @Inject('cool:cache')
  coolCache: ICoolCache;
 
  /**
   * 列表
   */
  async list(keyWord) {
    return this.coolPlugin.list(keyWord);
  }
 
  /**
   * 配置
   */
  async config(namespace: string, config) {
    await this.coolPlugin.setConfig(namespace, config);
  }
 
  /**
   * 获得配置信息
   * @param namespace
   */
  async getConfig(namespace: string) {
    return await this.coolPlugin.getConfig(namespace);
  }
 
  /**
   * 是否启用插件
   * @param namespace
   * @param enable
   */
  async enable(namespace: string, enable: number) {
    await this.coolPlugin.enable(namespace, enable);
  }
}