statistics.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  4. // 首页-数据动态统计
  5. class StatisticsController extends Controller {
  6. constructor(ctx) {
  7. super(ctx);
  8. this.service = this.ctx.service.statistics;
  9. }
  10. async index() {
  11. const patent = await this.service.patent(this.ctx.query);
  12. const product = await this.service.product(this.ctx.query);
  13. const users = await this.service.users(this.ctx.query);
  14. const data = await this.service.data(this.ctx.query);
  15. this.ctx.ok({ data: { patent, product, users, data } });
  16. }
  17. /**
  18. * 首页专利统计
  19. */
  20. async patent() {
  21. const data = await this.service.patent(this.ctx.query);
  22. this.ctx.ok({ data });
  23. }
  24. /**
  25. * 首页成果统计
  26. */
  27. async product() {
  28. const data = await this.service.product(this.ctx.query);
  29. this.ctx.ok({ data });
  30. }
  31. /**
  32. * 首页用户统计
  33. */
  34. async users() {
  35. const data = await this.service.users(this.ctx.query);
  36. this.ctx.ok({ data });
  37. }
  38. /**
  39. * 首页数据统计
  40. */
  41. async data() {
  42. const data = await this.service.data(this.ctx.query);
  43. this.ctx.ok({ data });
  44. }
  45. /**
  46. * 创新券统计
  47. */
  48. async ticket() {
  49. const data = await this.service.ticket(this.ctx.query);
  50. this.ctx.ok({ data });
  51. }
  52. }
  53. module.exports = CrudController(StatisticsController, {});