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
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
import { CoolController, BaseController } from '@cool-midway/core';
import { Body, Inject, Post } from '@midwayjs/core';
import { CountUserService } from '../../service/user';
import { CountOrderService } from '../../service/order';
import { CountGoodsService } from '../../service/goods';
 
/**
 * 首页统计
 */
@CoolController()
export class AdminCountHomeController extends BaseController {
  @Inject()
  countUserService: CountUserService;
 
  @Inject()
  countOrderService: CountOrderService;
 
  @Inject()
  countGoodsService: CountGoodsService;
 
  @Post('/userSummary', { summary: '用户概况' })
  async userSummary() {
    return this.ok(await this.countUserService.summary());
  }
 
  @Post('/userChart', { summary: '用户图表' })
  async userChart(
    // 天数
    @Body('dayCount') dayCount: number
  ) {
    return this.ok(await this.countUserService.chart(dayCount));
  }
 
  @Post('/orderSummary', { summary: '订单概况' })
  async orderSummary(
    // 类型 count-数量 amount-金额
    @Body('type') type: 'count' | 'amount'
  ) {
    return this.ok(await this.countOrderService.summary(type));
  }
 
  @Post('/orderChart', { summary: '订单图表' })
  async orderChart(
    // 天数
    @Body('dayCount') dayCount: number,
    // 类型 count-数量 amount-金额
    @Body('type') type: 'count' | 'amount'
  ) {
    return this.ok(await this.countOrderService.chart(dayCount, type));
  }
 
  @Post('/goodsRank', { summary: '商品排行' })
  async goodsRank(
    // 类型 count-数量 amount-金额
    @Body('type') type: 'count' | 'amount',
    // 条数
    @Body('limit') limit: number
  ) {
    return this.ok(await this.countGoodsService.rank(type, limit));
  }
 
  @Post('/goodsCategory', { summary: '商品分类' })
  async goodsCategory(
    // 类型 count-数量 amount-金额
    @Body('type') type: 'count' | 'amount'
  ) {
    return this.ok(await this.countGoodsService.category(type));
  }
}