Skip to content

Commit

Permalink
新增数据库自动化导入
Browse files Browse the repository at this point in the history
  • Loading branch information
apgzs committed Feb 27, 2021
1 parent 3bb0271 commit 2a08c83
Show file tree
Hide file tree
Showing 9 changed files with 894 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,3 +14,4 @@ run/
.tsbuildinfo
.tsbuildinfo.*
src/app/public/uploads/
typings/
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -10,6 +10,6 @@ RUN yarn
RUN yarn build

# 如果端口更换,这边可以更新一下
EXPOSE 7001
EXPOSE 8001

CMD ["npm", "run", "start"]
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 cool-team-official

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion src/app/modules/base/config.ts
Expand Up @@ -11,6 +11,6 @@ export default (app: Application) => {
// 模块描述
description: '基础的权限管理功能,包括登录,权限校验',
// 中间件
middlewares: [],
middlewares: ['baseAuthorityMiddleware', 'baseLogMiddleware'],
} as ModuleConfig;
};
52 changes: 52 additions & 0 deletions 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();
}
}
43 changes: 43 additions & 0 deletions 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);
}
}
4 changes: 3 additions & 1 deletion src/app/modules/base/service/sys/user.ts
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/configuration.ts
Expand Up @@ -3,16 +3,14 @@ import { ILifeCycle, IMidwayContainer } from '@midwayjs/core';
import { Application } from 'egg';
import * as orm from '@midwayjs/orm';
import * as cool from 'midwayjs-cool-core';
import * as oss from 'midwayjs-cool-oss';

@Configuration({
// 注意组件顺序 cool 有依赖orm组件, 所以必须放在,orm组件之后 cool的其他组件必须放在cool 核心组件之后
imports: [
// 必须,不可移除, https://typeorm.io 打不开? https://typeorm.biunav.com/zh/
orm,
// 必须,不可移除, cool-admin 官方组件 https://www.cool-js.com
cool,
oss
cool
]
})
export class ContainerLifeCycle implements ILifeCycle {
Expand All @@ -21,6 +19,7 @@ export class ContainerLifeCycle implements ILifeCycle {
app: Application;
// 应用启动完成
async onReady(container?: IMidwayContainer) {
console.log(container.baseDir)

}
// 应用停止
Expand Down

0 comments on commit 2a08c83

Please sign in to comment.