Browse Source

增加盘口详情获取

flyzto 7 tháng trước cách đây
mục cha
commit
bb2cd34a30
2 tập tin đã thay đổi với 29 bổ sung1 xóa
  1. 22 1
      server/models/Games.js
  2. 7 0
      server/routes/triangle.js

+ 22 - 1
server/models/Games.js

@@ -174,6 +174,27 @@ const getGamesList = () => {
   return gamesListMap;
 }
 
+/**
+ * 获取比赛盘口
+ */
+const getGamesEvents = (platform) => {
+  if (platform) {
+    return Object.values(GAMES.Relations).map(rel => rel[platform] ?? {});
+  }
+  const gamesEvents = {};
+  Object.values(GAMES.Relations).forEach(rel => {
+    Object.keys(rel).forEach(platform => {
+      const game = rel[platform];
+      const { eventId, events, special } = game;
+      if (!gamesEvents[platform]) {
+        gamesEvents[platform] = {};
+      }
+      gamesEvents[platform][eventId] = { eventId, events: { ...events, ...special } };
+    });
+  });
+  return gamesEvents;
+}
+
 /**
  * 更新关联比赛
  */
@@ -378,5 +399,5 @@ setInterval(() => {
 module.exports = {
   updateGamesList, updateGamesEvents, getGamesList,
   updateGamesRelation, getGamesRelation, removeGamesRelation,
-  getSolutions,
+  getGamesEvents, getSolutions,
 }

+ 7 - 0
server/routes/triangle.js

@@ -70,6 +70,13 @@ router.get('/get_games_relation', (req, res) => {
   });
 });
 
+// 获取比赛盘口
+router.get('/get_games_events', authMiddleware, (req, res) => {
+  const { platform } = req.query;
+  const gamesEvents = Games.getGamesEvents(platform);
+  res.sendSuccess(gamesEvents);
+});
+
 // 获取中单方案
 router.get('/get_solutions', authMiddleware, (req, res) => {
   Games.getSolutions().then(solutions => {