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
| import {
| CoolController,
| BaseController,
| TagTypes,
| CoolUrlTag,
| } from '@cool-midway/core';
| import { GoodsCommentEntity } from '../../entity/comment';
| import { UserInfoEntity } from '../../../user/entity/info';
| import { Body, Inject, Post } from '@midwayjs/core';
| import { GoodsCommentService } from '../../service/comment';
|
| /**
| * 商品评论
| */
| @CoolUrlTag({
| key: TagTypes.IGNORE_TOKEN,
| value: ['page'],
| })
| @CoolController({
| api: ['page'],
| entity: GoodsCommentEntity,
| insertParam: ctx => {
| return {
| userId: ctx.user.id,
| };
| },
| pageQueryOp: {
| fieldEq: ['a.goodsId', 'a.orderId'],
| select: ['a.*', 'b.nickName', 'b.avatarUrl'],
| join: [
| {
| entity: UserInfoEntity,
| alias: 'b',
| condition: 'a.userId = b.id',
| },
| ],
| },
| })
| export class AppGoodsCommentController extends BaseController {
| @Inject()
| ctx;
|
| @Inject()
| goodsCommentService: GoodsCommentService;
|
| @Post('/submit', { summary: '提交评论' })
| async submit(
| @Body('data') data: GoodsCommentEntity,
| @Body('orderId') orderId: number
| ) {
| return this.ok(
| await this.goodsCommentService.submit(this.ctx.user.id, orderId, data)
| );
| }
| }
|
|