wangzhibo
2026-07-16 bac4362a0b7726d38a23d38f0d7913f2c2bab262
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
import { SpaceInfoEntity } from './../entity/info';
import { Inject, Provide } from '@midwayjs/core';
import { BaseService, MODETYPE } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { PluginService } from '../../plugin/service/info';
 
/**
 * 文件信息
 */
@Provide()
export class SpaceInfoService extends BaseService {
  @InjectEntityModel(SpaceInfoEntity)
  spaceInfoEntity: Repository<SpaceInfoEntity>;
 
  @Inject()
  pluginService: PluginService;
 
  /**
   * 新增
   */
  async add(param) {
    const result = await this.pluginService.invoke('upload', 'getMode');
    const config = await this.pluginService.getConfig('upload');
    if (result.mode == MODETYPE.LOCAL) {
      param.key = param.url.replace(config.domain, '');
    }
    return super.add(param);
  }
}