count.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  4. // 统计
  5. class CountController extends Controller {
  6. constructor(ctx) {
  7. super(ctx);
  8. this.service = this.ctx.service.count;
  9. }
  10. /**
  11. * 首页四部分统计
  12. */
  13. async index() {
  14. const res = await this.service.index(this.ctx.query);
  15. this.ctx.ok({ data: res });
  16. }
  17. /**
  18. * 下面的四个是首页四部分详情,带条件,至少传入 r_mobile
  19. */
  20. async yesterday() {
  21. const res = await this.service.yesterday(this.ctx.query, 'find');
  22. this.ctx.ok({ data: res });
  23. }
  24. async week() {
  25. const res = await this.service.week(this.ctx.query, 'find');
  26. this.ctx.ok({ data: res });
  27. }
  28. async month() {
  29. const res = await this.service.month(this.ctx.query, 'find');
  30. this.ctx.ok({ data: res });
  31. }
  32. async group() {
  33. const res = await this.service.group(this.ctx.query, 'find');
  34. this.ctx.ok({ data: res });
  35. }
  36. }
  37. module.exports = CrudController(CountController, {});