修改文件上传为插件方式

This commit is contained in:
cool 2024-02-19 17:06:10 +08:00
parent f5b4fd572a
commit 2a7958b7c6
2 changed files with 7 additions and 5 deletions

View File

@ -8,8 +8,8 @@ import {
CoolTag,
} from '@cool-midway/core';
import { Context } from '@midwayjs/koa';
import { CoolFile } from '@cool-midway/file';
import { BaseSysParamService } from '../../service/sys/param';
import { PluginService } from '../../../plugin/service/info';
/**
*
@ -19,7 +19,7 @@ import { BaseSysParamService } from '../../service/sys/param';
@CoolController()
export class BaseAppCommController extends BaseController {
@Inject()
coolFile: CoolFile;
pluginService: PluginService;
@Inject()
ctx: Context;
@ -57,7 +57,8 @@ export class BaseAppCommController extends BaseController {
*/
@Post('/upload', { summary: '文件上传' })
async upload() {
return this.ok(await this.coolFile.upload(this.ctx));
const file = await this.pluginService.getInstance('upload');
return this.ok(await file.upload(this.ctx));
}
/**
@ -65,6 +66,7 @@ export class BaseAppCommController extends BaseController {
*/
@Get('/uploadMode', { summary: '文件上传模式' })
async uploadMode() {
return this.ok(await this.coolFile.getMode());
const file = await this.pluginService.getInstance('upload');
return this.ok(await file.getMode());
}
}

View File

@ -41,7 +41,7 @@ export default () => {
// 刷新token 过期时间,单位秒
refreshExpire: 60 * 60 * 24 * 30,
// jwt 秘钥
secret: '98591b81ce3111eebb6f5ba31567ea59',
secret: 'cool-app-xxxxxx',
},
} as ModuleConfig;
};