Forráskód Böngészése

完善测试数据

flyzto 3 hónapja
szülő
commit
72ec4c1344

+ 8 - 1
server/models/GamesPs.js

@@ -503,8 +503,15 @@ const fetchGamesRelation = async (mk='') => {
   });
 }
 
-const getGamesRelation = ({ mk, listEvents } = {}) => {
+const getGamesRelation = ({ mk, ids, listEvents } = {}) => {
+  let idsSet = null;
+  if (ids?.length) {
+    idsSet = new Set(ids);
+  }
   const relations = Object.values(GAMES.Relations).filter(item => {
+    if (idsSet && !idsSet.has(item.id)) {
+      return false;
+    }
     if (typeof(mk) === 'undefined' || mk === '') {
       return true;
     }

+ 4 - 2
server/routes/pstery.js

@@ -60,8 +60,10 @@ router.get('/get_filtered_leagues', (req, res) => {
 
 // 获取关联列表
 router.get('/get_games_relation', (req, res) => {
-  const { mk } = req.query;
-  const gamesRelation = Games.getGamesRelation({ mk });
+  const { mk, id, le } = req.query;
+  const ids = id?.split(',').map(item => +item.trim()).filter(item => !!item) ?? [];
+  const listEvents = le === 'true';
+  const gamesRelation = Games.getGamesRelation({ mk, ids, listEvents });
   res.sendSuccess(gamesRelation);
 });
 

+ 70 - 186
web/apps/web-antd/src/views/match/datatest/index.vue

@@ -1,92 +1,8 @@
-<template>
-  <div class="data-test-container">
-    <div class="page-header">
-      <h1>数据测试</h1>
-      <p>用于测试和验证比赛数据的页面</p>
-    </div>
-
-    <div class="content-area">
-      <div class="test-panel">
-        <h2>测试数据展示</h2>
-        <div class="data-display">
-          <div class="data-item">
-            <label>数据源:</label>
-            <span>比赛管理系统</span>
-          </div>
-          <div class="data-item">
-            <label>更新时间:</label>
-            <span>{{ currentTime }}</span>
-          </div>
-        </div>
-
-        <div class="radio-options">
-          <div class="radio-group">
-            <label class="radio-label">
-              <input
-                type="radio"
-                name="testMode"
-                value="1"
-                v-model="selectedTestMode"
-                class="radio-input"
-              >
-              <span class="radio-text">今日</span>
-            </label>
-            <label class="radio-label">
-              <input
-                type="radio"
-                name="testMode"
-                value="0"
-                v-model="selectedTestMode"
-                class="radio-input"
-              >
-              <span class="radio-text">早盘</span>
-            </label>
-            <label class="radio-label">
-              <input
-                type="radio"
-                name="testMode"
-                value=""
-                v-model="selectedTestMode"
-                class="radio-input"
-              >
-              <span class="radio-text">全部</span>
-            </label>
-          </div>
-        </div>
-
-        <div class="action-buttons">
-          <Button @click="refreshData" :disabled="buttonDisabled">
-            刷新数据
-          </Button>
-          <Button @click="runTest(true)" :disabled="buttonDisabled">
-            有欢乐值
-          </Button>
-          <Button @click="runTest(false)" :disabled="buttonDisabled">
-            无欢乐值
-          </Button>
-          <Button @click="filterLive" :disabled="buttonDisabled">
-            筛选滚球
-          </Button>
-          <Button @click="filterHalf" :disabled="buttonDisabled">
-            筛选中场
-          </Button>
-        </div>
-      </div>
-    </div>
-
-    <div class="data-table" v-if="prettyData">
-      <div class="data-count" v-if="dataCount">
-        <span>数据总数:{{ dataCount }}</span>
-      </div>
-      <vue-json-pretty :data="prettyData" :indent="2" :deep="2" :key="prettyKey" :showDoubleQuotes="false"></vue-json-pretty>
-    </div>
-  </div>
-</template>
-
 <script setup>
 import { ref, watch, onMounted } from 'vue';
 import { requestClient } from '#/api/request';
-import { Button, message, InputNumber } from 'ant-design-vue';
+import { Page } from '@vben/common-ui';
+import { Form, Input, RadioGroup, Radio, Button, message } from 'ant-design-vue';
 
 import dayjs from 'dayjs';
 import VueJsonPretty from 'vue-json-pretty';
@@ -96,6 +12,8 @@ const currentTime = ref('');
 const gamesRelation = ref([]);
 const gamesSolution = ref({});
 const selectedTestMode = ref('');
+const idsText = ref('');
+const idsList = ref([]);
 const buttonDisabled = ref(false);
 
 const prettyData = ref(null);
@@ -110,6 +28,10 @@ const updateTime = () => {
   currentTime.value = new Date().toLocaleString('zh-CN')
 }
 
+const idsInput = (value) => {
+  idsList.value = idsText.value.split(',').map(item => +item.trim()).filter(item => !!item);
+}
+
 const refreshData = () => {
   buttonDisabled.value = true;
   updateTime();
@@ -197,114 +119,76 @@ const filterHalf = () => {
   console.log('halfSolutions', halfSolutions);
 }
 
-// const currentTime = ref('')
-
-// const updateTime = () => {
-//   currentTime.value = new Date().toLocaleString('zh-CN')
-// }
-
-// const refreshData = () => {
-//   updateTime()
-//   console.log('数据已刷新')
-// }
-
-// const runTest = () => {
-//   console.log('开始运行测试...')
-//   // 这里可以添加具体的测试逻辑
-// }
+const filterTarget = () => {
+  requestClient.get('/pstery/get_games_relation', { params: { mk: selectedTestMode.value, le: true, id: idsText.value } })
+  .then(data => {
+    dataCount.value = `${data.length}`;
+    showDataPretty(data, 2);
+    console.log('data', data);
+  })
+  .catch(err => {
+    message.error('数据获取失败');
+    console.error('数据获取失败', err);
+  })
+}
 
 onMounted(() => {
   refreshData();
 })
 </script>
 
-<style lang="scss" scoped>
-.data-test-container {
-  padding: 20px;
-
-  .page-header {
-    margin-bottom: 30px;
-
-    h1 {
-      font-size: 24px;
-      font-weight: bold;
-      margin-bottom: 8px;
-      color: #333;
-    }
-
-    p {
-      color: #666;
-      font-size: 14px;
-    }
-  }
-
-  .content-area {
-    .test-panel {
-      background: #fff;
-      border-radius: 8px;
-      padding: 24px;
-      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
-
-      h2 {
-        font-size: 18px;
-        font-weight: 600;
-        margin-bottom: 20px;
-        color: #333;
-      }
-
-      .data-display {
-        margin-bottom: 24px;
-
-        .data-item {
-          display: flex;
-          align-items: center;
-          margin-bottom: 12px;
-
-          label {
-            font-weight: 500;
-            color: #555;
-            min-width: 100px;
-          }
-
-          span {
-            color: #333;
-
-            &.status-success {
-              color: #52c41a;
-              font-weight: 500;
-            }
-          }
-        }
-      }
-
-      .radio-options {
-        margin-bottom: 20px;
-
-        .radio-group {
-          display: flex;
-          gap: 20px;
-
-          .radio-label {
-            display: flex;
-            align-items: center;
-            cursor: pointer;
-            user-select: none;
+<template>
+  <Page title="数据测试" description="用于测试和验证比赛数据的页面">
+
+    <Form>
+      <Form.Item label="数据源:">
+        <span>比赛管理系统</span>
+      </Form.Item>
+      <Form.Item label="更新时间:">
+        <span>{{ currentTime }}</span>
+      </Form.Item>
+      <Form.Item label="测试模式:">
+        <RadioGroup v-model:value="selectedTestMode">
+          <Radio value="1">今日</Radio>
+          <Radio value="0">早盘</Radio>
+          <Radio value="">全部</Radio>
+        </RadioGroup>
+      </Form.Item>
+      <Form.Item label="ID列表:">
+        <Input v-model:value="idsText" @input="idsInput" />
+      </Form.Item>
+      <Form.Item>
+        <Button @click="refreshData" :disabled="buttonDisabled">
+          刷新数据
+        </Button>
+        <Button @click="runTest(true)" :disabled="buttonDisabled">
+          有欢乐值
+        </Button>
+        <Button @click="runTest(false)" :disabled="buttonDisabled">
+          无欢乐值
+        </Button>
+        <Button @click="filterLive" :disabled="buttonDisabled">
+          筛选滚球
+        </Button>
+        <Button @click="filterHalf" :disabled="buttonDisabled">
+          筛选中场
+        </Button>
+        <Button @click="filterTarget" :disabled="!idsList.length">
+          目标赛事
+        </Button>
+      </Form.Item>
+    </Form>
 
-            .radio-input {
-              margin-right: 8px;
-              cursor: pointer;
-            }
+    <div class="data-table" v-if="prettyData">
+      <div class="data-count" v-if="dataCount">
+        <span>数据总数:{{ dataCount }}</span>
+      </div>
+      <vue-json-pretty :data="prettyData" :indent="2" :deep="2" :key="prettyKey" :showDoubleQuotes="false"></vue-json-pretty>
+    </div>
+  </Page>
+</template>
 
-            .radio-text {
-              font-size: 14px;
-              color: #333;
-            }
-          }
-        }
-      }
-    }
-  }
-}
+<style lang="scss" scoped>
 .data-table {
   padding: 20px;
 }