iviActiveUserController.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. // ivi活跃用户总数统计分析模块
  4. class IviActiveUserController extends Controller {
  5. // ivi活跃用户总数
  6. async index() {
  7. const { ctx, service } = this;
  8. // 校验参数 组装参数
  9. const payload = ctx.validate();
  10. // 调用 Service 进行业务处理
  11. let data = '';
  12. switch (payload.type) {
  13. case '0':
  14. data = await service.tRbacUserService.index(payload, 'activeIviTotal');
  15. break;
  16. case '1':
  17. data = await service.tRbacUserService.index(payload, 'activeIviMonth');
  18. break;
  19. case '2':
  20. data = await service.tRbacUserService.index(payload, 'activeIviYear');
  21. break;
  22. default:
  23. break;
  24. }
  25. // 设置响应内容和响应状态码
  26. ctx.success({ data });
  27. }
  28. // ivi活跃用户位置分布
  29. async location() {
  30. const { ctx, service } = this;
  31. // 调用 Service 进行业务处理
  32. const data = await service.onlineUserService2.place('iviActiveLocation');
  33. // 设置响应内容和响应状态码
  34. ctx.success({ data });
  35. }
  36. // ivi活跃用户性别和年龄
  37. async sexAndAge() {
  38. const { ctx, service } = this;
  39. // 调用 Service 进行业务处理
  40. const data = await service.tRbacUserService.sexAndAge('activeIviSexAndAgeTotal');
  41. // 设置响应内容和响应状态码
  42. ctx.success({ data });
  43. }
  44. }
  45. module.exports = IviActiveUserController;