appUserController.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. // APP用户总数统计分析模块
  4. class AppUserController extends Controller {
  5. // app用户总数
  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, 'appTotal');
  16. // 设置响应内容和响应状态码
  17. ctx.success({ data });
  18. }
  19. }
  20. // app用户位置分布
  21. async location() {
  22. const { ctx, service } = this;
  23. // 调用 Service 进行业务处理
  24. if (ctx.isDev()) {
  25. const data = ctx.getArea();
  26. ctx.success({ data });
  27. } else {
  28. const data = await service.onlineUserService2.place('appLocation');
  29. // 设置响应内容和响应状态码
  30. ctx.success({ data });
  31. }
  32. }
  33. // app车主性别和年龄
  34. async sexAndAge() {
  35. const { ctx, service } = this;
  36. // 调用 Service 进行业务处理
  37. if (ctx.isDev()) {
  38. const data = ctx.getSex2Age();
  39. ctx.success({ data });
  40. } else {
  41. const data = await service.tRbacUserService.sexAndAge('appSexAndAgeTotal');
  42. // 设置响应内容和响应状态码
  43. ctx.success({ data });
  44. }
  45. }
  46. }
  47. module.exports = AppUserController;