diff --git a/src/app/modules/base/config.ts b/src/app/modules/base/config.ts index 8851ef2..5b1fca0 100644 --- a/src/app/modules/base/config.ts +++ b/src/app/modules/base/config.ts @@ -11,6 +11,6 @@ export default (app: Application) => { // 模块描述 description: '基础的权限管理功能,包括登录,权限校验', // 中间件 - middlewares: [], + middlewares: ['baseAuthorityMiddleware', 'baseLogMiddleware'], } as ModuleConfig; }; diff --git a/src/app/modules/base/controller/admin/plugin/info.ts b/src/app/modules/base/controller/admin/plugin/info.ts new file mode 100644 index 0000000..0448d4e --- /dev/null +++ b/src/app/modules/base/controller/admin/plugin/info.ts @@ -0,0 +1,52 @@ +import { Body, Get, Inject, Post, Provide, Query } from '@midwayjs/decorator'; +import { CoolController, BaseController } from 'midwayjs-cool-core'; +import { BasePluginInfoService } from '../../../service/plugin/info'; + +/** + * 插件 + */ +@Provide() +@CoolController() +export class BasePluginInfoController extends BaseController { + + @Inject() + basePluginInfoService: BasePluginInfoService; + /** + * 插件列表 + */ + @Post('/list') + async list(@Body() keyWord: string) { + return this.ok(await this.basePluginInfoService.list(keyWord)) + } + + /** + * 配置 + * @param namespace + * @param config + */ + @Post('/config') + async config(@Body() namespace: string, @Body() config: any) { + await this.basePluginInfoService.config(namespace, config); + return this.ok(); + } + + /** + * 配置 + * @param namespace + * @param config + */ + @Get('/getConfig') + async getConfig(@Query() namespace: string) { + return this.ok(await this.basePluginInfoService.getConfig(namespace)); + } + + /** + * 启用插件 + * @param enable + */ + @Post('/enable') + async enable(@Body() namespace: string, @Body() enable: number) { + await this.basePluginInfoService.enable(namespace, enable); + return this.ok(); + } +} \ No newline at end of file diff --git a/src/app/modules/base/service/plugin/info.ts b/src/app/modules/base/service/plugin/info.ts new file mode 100644 index 0000000..1b15477 --- /dev/null +++ b/src/app/modules/base/service/plugin/info.ts @@ -0,0 +1,43 @@ +import { Inject, Provide } from '@midwayjs/decorator'; +import { BaseService, CoolPlugin } from 'midwayjs-cool-core'; + +/** + * 插件 + */ +@Provide() +export class BasePluginInfoService extends BaseService { + + @Inject('cool:coolPlugin') + coolPlugin: CoolPlugin; + + /** + * 列表 + */ + 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); + } +} \ No newline at end of file diff --git a/src/app/modules/base/service/sys/user.ts b/src/app/modules/base/service/sys/user.ts index e1b0cce..111e562 100644 --- a/src/app/modules/base/service/sys/user.ts +++ b/src/app/modules/base/service/sys/user.ts @@ -74,7 +74,9 @@ export class BaseSysUserService extends BaseService { * 获得个人信息 */ async person() { - return await this.baseSysUserEntity.findOne({ id: this.ctx.admin.userId }) + const info = await this.baseSysUserEntity.findOne({ id: this.ctx.admin.userId }); + delete info.password; + return info; } /**