iviUserController.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. // ivi用户总数统计分析模块
  4. class IviUserController extends Controller {
  5. // ivi用户总数
  6. async index() {
  7. const { ctx, service } = this;
  8. // 校验参数 组装参数
  9. const payload = ctx.validate();
  10. // 调用 Service 进行业务处理
  11. if (ctx.isDev()) {
  12. const data = ctx.getData(payload);
  13. ctx.success({ data });
  14. } else {
  15. const data = await service.tRbacUserService.index(payload, 'iviTotal');
  16. // 设置响应内容和响应状态码
  17. ctx.success({ data });
  18. }
  19. }
  20. // ivi用户位置分布
  21. async location() {
  22. const { ctx, service } = this;
  23. // 校验参数 组装参数
  24. // 调用 Service 进行业务处理
  25. if (ctx.isDev()) {
  26. const data = ctx.getArea();
  27. ctx.success({ data });
  28. } else {
  29. const data = await service.onlineUserService2.place('iviLocation');
  30. // 设置响应内容和响应状态码
  31. ctx.success({ data });
  32. }
  33. }
  34. // ivi车主性别和年龄
  35. async sexAndAge() {
  36. const { ctx, service } = this;
  37. // 调用 Service 进行业务处理
  38. if (ctx.isDev()) {
  39. const data = ctx.getSex2Age();
  40. ctx.success({ data });
  41. } else {
  42. const data = await service.tRbacUserService.sexAndAge('iviSexAndAgeTotal');
  43. // 设置响应内容和响应状态码
  44. ctx.success({ data });
  45. }
  46. }
  47. }
  48. module.exports = IviUserController;