wangrong
2022-03-16 a45591fc22c088fe45fafb651b0c4575cc5c2f0f
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { Provide, Inject, Get, Post,Query, Body, ALL } from '@midwayjs/decorator';
import {
  CoolController,
  BaseController,
  ICoolCache,
  ICoolFile,
} from '@cool-midway/core';
import { Context } from 'egg';
import { DataService } from '../service/dataapi/dataapi';
 
/**
 * 通用数据的后台接口
 */
@Provide()
@CoolController()
export class DataController extends BaseController {
  @Inject('cool:eps:open')
  eps;
 
  @Inject('cool:cache')
  coolCache: ICoolCache;
 
  @Inject('cool:file')
  coolFile: ICoolFile;
 
  @Inject()
  ctx: Context;
  
  @Inject()
  dataService: DataService;
 
  /**
   * 实体信息与路径
   * @returns
   */
  @Get('/eps', { summary: '实体信息与路径' })
  public async getEps() {
    console.log(this.coolCache.getMode());
    return this.ok(this.eps);
  }
 
  /**
   * 文件上传
   */
  @Post('/upload', { summary: '文件上传' })
  async upload() {
    return this.ok(await this.coolFile.upload(this.ctx));
  }
 
  /**
   * 文件上传模式,本地或者云存储
   */
  @Get('/uploadMode', { summary: '文件上传模式' })
  async uploadMode() {
    return this.ok(this.coolFile.getMode());
  }
 
  
  /**
   * 获得数据
   */
   @Get('/getdata', { summary: '数据接口' })
   async getData(@Query(ALL) params: any) {
     console.log(params);
     return this.ok(await this.dataService.getData(params));
   }
 
   /**
    * 获得数据
    */
   @Post('/postdata', { summary: '数据接口' })
   async postData(@Query(ALL) params: any) {
     return this.ok(await this.dataService.getData(params));
   }
 
  
}