router.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. /**
  3. * @param {Egg.Application} app - egg application
  4. */
  5. const os = require('os');
  6. function getIPAdress() {
  7. const interfaces = os.networkInterfaces();
  8. for (const devName in interfaces) {
  9. const iface = interfaces[devName];
  10. for (let i = 0; i < iface.length; i++) {
  11. const alias = iface[i];
  12. if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
  13. return alias.address;
  14. }
  15. }
  16. }
  17. }
  18. module.exports = app => {
  19. const { router, controller } = app;
  20. const { routePrefix, cluster } = app.config;
  21. const ipAddress = getIPAdress();
  22. console.log(`前缀:http://${ipAddress}:${cluster.listen.port}${routePrefix}`);
  23. router.get('/', controller.home.index);
  24. router.post('/', controller.home.util);
  25. require('./z_router/user')(app); // 比赛模块用户
  26. require('./z_router/match')(app); // 比赛信息
  27. require('./z_router/matchGroup')(app); // 比赛组别
  28. require('./z_router/matchProject')(app); // 组别项目
  29. require('./z_router/teamApply')(app); // 组队申请
  30. require('./z_router/matchSign')(app); // 赛事报名
  31. require('./z_router/bill')(app); // 账单
  32. require('./z_router/payOrder')(app); // 支付订单
  33. require('./z_router/matchTeamGroup')(app); // 小组赛设置
  34. require('./z_router/matchAddress')(app); // 场地设置
  35. require('./z_router/matchSmallGroupSchedule')(app); // 小组赛赛程
  36. require('./z_router/eliminate')(app); // 淘汰赛赛程
  37. };