mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-01-18 11:28:10 +00:00
完善插件
This commit is contained in:
parent
3bb0271d32
commit
f760817807
@ -11,6 +11,6 @@ export default (app: Application) => {
|
|||||||
// 模块描述
|
// 模块描述
|
||||||
description: '基础的权限管理功能,包括登录,权限校验',
|
description: '基础的权限管理功能,包括登录,权限校验',
|
||||||
// 中间件
|
// 中间件
|
||||||
middlewares: [],
|
middlewares: ['baseAuthorityMiddleware', 'baseLogMiddleware'],
|
||||||
} as ModuleConfig;
|
} as ModuleConfig;
|
||||||
};
|
};
|
||||||
|
|||||||
52
src/app/modules/base/controller/admin/plugin/info.ts
Normal file
52
src/app/modules/base/controller/admin/plugin/info.ts
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/app/modules/base/service/plugin/info.ts
Normal file
43
src/app/modules/base/service/plugin/info.ts
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -74,7 +74,9 @@ export class BaseSysUserService extends BaseService {
|
|||||||
* 获得个人信息
|
* 获得个人信息
|
||||||
*/
|
*/
|
||||||
async person() {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user