| | |
| | | import { |
| | | mockActivityPlayerDetail, |
| | | mockRatingScheme, |
| | | mockCurrentJudgeInfo, |
| | | mockJudgeRatings, |
| | | mockCurrentJudgeRating, |
| | | mockAverageScore, |
| | | createMockResponse |
| | | } from './mockData.js' |
| | | |
| | | const GRAPHQL_ENDPOINT = '/api/graphql' |
| | | |
| | | // 模拟数据开关 - 设置为true时使用模拟数据 |
| | | // 已切换到真实数据模式 |
| | | const USE_MOCK_DATA = false |
| | | |
| | | async function graphqlRequest(query, variables = {}) { |
| | | const response = await fetch(GRAPHQL_ENDPOINT, { |
| | |
| | | * 获取比赛报名详情(用于评分) |
| | | */ |
| | | export function getActivityPlayerDetail(id) { |
| | | if (USE_MOCK_DATA) { |
| | | return Promise.resolve(createMockResponse({ |
| | | activityPlayerDetail: mockActivityPlayerDetail |
| | | })) |
| | | } |
| | | return graphqlRequest(GET_ACTIVITY_PLAYER_DETAIL, { id }) |
| | | } |
| | | |
| | |
| | | * 保存比赛报名评分 |
| | | */ |
| | | export function saveActivityPlayerRating(input) { |
| | | if (USE_MOCK_DATA) { |
| | | console.log('模拟保存评分数据:', input) |
| | | return Promise.resolve(createMockResponse({ |
| | | saveActivityPlayerRating: true |
| | | })) |
| | | } |
| | | return graphqlRequest(SAVE_ACTIVITY_PLAYER_RATING, { input }) |
| | | } |
| | | |
| | | const GET_JUDGE_RATINGS_FOR_PLAYER = ` |
| | | query GetJudgeRatingsForPlayer($activityPlayerId: ID!) { |
| | | judgeRatingsForPlayer(activityPlayerId: $activityPlayerId) { |
| | | judgeId |
| | | judgeName |
| | | totalScore |
| | | status |
| | | isCurrentJudge |
| | | } |
| | | } |
| | | ` |
| | | |
| | | /** |
| | | * 获取指定选手的所有评委评分状态 |
| | | */ |
| | | export function getJudgeRatingsForPlayer(activityPlayerId) { |
| | | if (USE_MOCK_DATA) { |
| | | return Promise.resolve(createMockResponse({ |
| | | judgeRatingsForPlayer: mockJudgeRatings |
| | | })) |
| | | } |
| | | return graphqlRequest(GET_JUDGE_RATINGS_FOR_PLAYER, { activityPlayerId }) |
| | | } |
| | | |
| | | const GET_CURRENT_JUDGE_RATING = ` |
| | | query GetCurrentJudgeRating($activityPlayerId: ID!) { |
| | | currentJudgeRating(activityPlayerId: $activityPlayerId) { |
| | | id |
| | | totalScore |
| | | status |
| | | remark |
| | | items { |
| | | ratingItemId |
| | | ratingItemName |
| | | score |
| | | weightedScore |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | |
| | | /** |
| | | * 获取当前评委对指定选手的评分 |
| | | */ |
| | | export function getCurrentJudgeRating(activityPlayerId) { |
| | | if (USE_MOCK_DATA) { |
| | | return Promise.resolve(createMockResponse({ |
| | | currentJudgeRating: mockCurrentJudgeRating |
| | | })) |
| | | } |
| | | return graphqlRequest(GET_CURRENT_JUDGE_RATING, { activityPlayerId }) |
| | | } |
| | | |
| | | const GET_AVERAGE_SCORE_FOR_PLAYER = ` |
| | | query GetAverageScoreForPlayer($activityPlayerId: ID!) { |
| | | averageScoreForPlayer(activityPlayerId: $activityPlayerId) |
| | | } |
| | | ` |
| | | |
| | | /** |
| | | * 获取指定选手的平均分 |
| | | */ |
| | | export function getAverageScoreForPlayer(activityPlayerId) { |
| | | if (USE_MOCK_DATA) { |
| | | return Promise.resolve(createMockResponse({ |
| | | averageScoreForPlayer: mockAverageScore |
| | | })) |
| | | } |
| | | return graphqlRequest(GET_AVERAGE_SCORE_FOR_PLAYER, { activityPlayerId }) |
| | | } |
| | | |
| | | const GET_CURRENT_JUDGE_INFO = ` |
| | | query GetCurrentJudgeInfo { |
| | | currentJudgeInfo { |
| | | id |
| | | name |
| | | phone |
| | | description |
| | | } |
| | | } |
| | | ` |
| | | |
| | | /** |
| | | * 获取当前评委信息 |
| | | */ |
| | | export function getCurrentJudgeInfo() { |
| | | if (USE_MOCK_DATA) { |
| | | return Promise.resolve(createMockResponse({ |
| | | currentJudgeInfo: mockCurrentJudgeInfo |
| | | })) |
| | | } |
| | | return graphqlRequest(GET_CURRENT_JUDGE_INFO) |
| | | } |