wangzhibo
6 天以前 7dcc2997614f849258091f5d66e648317a40d323
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
import { CoolController, BaseController } from '@cool-midway/core';
import { Body, Inject, Post } from '@midwayjs/core';
import { AppFeedbackService } from '../../service/feedback';
import { AppFeedbackEntity } from '../../entity/feedback';
 
/**
 * 意见反馈
 */
@CoolController({
  api: ['page', 'info'],
  entity: AppFeedbackEntity,
  insertParam: ctx => {
    return {
      userId: ctx.user.id,
    };
  },
  pageQueryOp: {
    fieldEq: ['a.type'],
    where: ctx => {
      const userId = ctx.user.id;
      return [['a.userId = :userId', { userId }]];
    },
  },
})
export class AppAppFeedbackController extends BaseController {
  @Inject()
  appFeedbackService: AppFeedbackService;
 
  @Inject()
  ctx;
 
  @Post('/submit', { summary: '提交意见反馈' })
  async submit(@Body() info) {
    info.userId = this.ctx.user.id;
    await this.appFeedbackService.submit(info);
    return this.ok();
  }
}