home.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. class HomeController extends Controller {
  4. constructor(ctx) {
  5. super(ctx);
  6. this.createRule = {
  7. startTime: { type: 'number', min: 0, required: false }, // 开始时间的时间戳 包含
  8. endTime: { type: 'number', min: 0, required: false }, // 结束时间的时间戳 不包含(客户端处理结束时间 下一日 ,下一月第一日 ,下一年第一日)
  9. };
  10. }
  11. async index() {
  12. const { ctx } = this;
  13. ctx.body = 'hi, egg';
  14. }
  15. async getMenu() {
  16. const { ctx, service } = this;
  17. const payload = ctx.validate({});
  18. if (ctx.isDev()) {
  19. const data = [
  20. 'BR01', 'BR0101', 'BR0102', 'BR0103', 'BR0104',
  21. 'BR02', 'BR0201', 'BR0202', 'BR0203', 'BR03',
  22. 'BR0301', 'BR0302', 'BR0303', 'BR0304', 'BR0305', 'BR0306', 'BR0307',
  23. 'BR04', 'BR0401', 'BR0402', 'BR0403', 'BR0404',
  24. 'BR05', 'BR0501', 'BR0502', 'BR0503', 'BR0504', 'BR0505', 'BR0506',
  25. 'BR06', 'BR0601', 'BR0602', 'BR0603', 'BR0604',
  26. 'BR07', 'BR0701', 'BR0702',
  27. 'BR08', 'BR0801', 'BR0802', 'BR0803',
  28. 'BR09', 'BR0901', 'BR0902', 'BR0903',
  29. 'BR10', 'BR1001', 'BR1002', 'BR1003',
  30. 'BR11', 'BR1101', 'BR1102',
  31. 'BR12', 'BR1201', 'BR1202',
  32. 'BR13', 'BR1301', 'BR1302', 'BR1303',
  33. 'BR14', 'BR1401', 'BR1402', 'BR1403',
  34. 'BR15', 'BR1501', 'BR1502', 'BR1503',
  35. 'BR16', 'BR1601',
  36. 'BR17', 'BR1701', 'BR1702', 'BR1703', 'BR1704', 'BR1705', 'BR1706', 'BR1707', 'BR1708', 'BR1709', 'BR1710', 'BR1711', 'BR1712', 'BR1713', 'BR1714',
  37. 'BR18', 'BR1801', 'BR1802', 'BR1803', 'BR1804',
  38. 'BR19', 'BR1901',
  39. 'BR20', 'BR2001', 'BR2002', 'BR2003', 'BR2004',
  40. 'BR21', 'BR2101', 'BR2102', 'BR2103', 'BR2104',
  41. 'BR22', 'BR2201', 'BR2202', 'BR2203',
  42. 'BR23', 'BR2301',
  43. 'BR24', 'BR2401', 'BR2402', 'BR2403', 'BR2404', 'BR2405',
  44. ];
  45. ctx.success({ data });
  46. } else {
  47. const data = await service.otherService.rbac(payload);
  48. ctx.success({ data });
  49. }
  50. }
  51. async task() {
  52. const { ctx, service } = this;
  53. const { startTime, endTime } = ctx.validate(this.createRule);
  54. await service.statisticsService.task(null, startTime, endTime);
  55. ctx.body = 'complete';
  56. }
  57. }
  58. module.exports = HomeController;