From 3714621173c606c4c58439ed8941100ce9ddea14 Mon Sep 17 00:00:00 2001
From: Codex Assistant <codex@example.com>
Date: 星期三, 05 十一月 2025 15:10:49 +0800
Subject: [PATCH] bug
---
web/src/api/activityPlayer.js | 205 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 187 insertions(+), 18 deletions(-)
diff --git a/web/src/api/activityPlayer.js b/web/src/api/activityPlayer.js
index 9eb3d43..204ce15 100644
--- a/web/src/api/activityPlayer.js
+++ b/web/src/api/activityPlayer.js
@@ -8,25 +8,145 @@
createMockResponse
} from './mockData.js'
-const GRAPHQL_ENDPOINT = '/api/graphql'
+import { API_CONFIG, graphqlRequest } from '@/config/api'
// 妯℃嫙鏁版嵁寮�鍏� - 璁剧疆涓簍rue鏃朵娇鐢ㄦā鎷熸暟鎹�
-// 宸插垏鎹㈠埌鐪熷疄鏁版嵁妯″紡
const USE_MOCK_DATA = false
-async function graphqlRequest(query, variables = {}) {
- const response = await fetch(GRAPHQL_ENDPOINT, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ query, variables })
- })
- if (!response.ok) {
- const text = await response.text()
- throw new Error(`HTTP ${response.status}: ${text}`)
+// GraphQL鏌ヨ璇彞
+const GET_ACTIVITY_PLAYERS_QUERY = `
+ query GetActivityPlayers($activityId: ID!, $page: Int!, $size: Int!, $name: String) {
+ activityPlayers(activityId: $activityId, page: $page, size: $size, name: $name) {
+ content {
+ id
+ playerId
+ activityId
+ signupTime
+ state
+ stateName
+ player {
+ id
+ name
+ phone
+ regionId
+ region {
+ id
+ name
+ }
+ }
+ }
+ totalElements
+ page
+ size
+ }
}
- const result = await response.json()
- if (result.errors) throw new Error(result.errors.map(e => e.message).join('\n'))
- return result.data
+`
+
+const GET_ACTIVITY_PLAYER_QUERY = `
+ query GetActivityPlayer($id: ID!) {
+ activityPlayer(id: $id) {
+ id
+ playerId
+ activityId
+ signupTime
+ state
+ stateName
+ player {
+ id
+ name
+ phone
+ regionId
+ region {
+ id
+ name
+ }
+ }
+ activity {
+ id
+ name
+ description
+ }
+ attachments {
+ id
+ fileName
+ fileUrl
+ fileSize
+ uploadTime
+ }
+ }
+ }
+`
+
+const SAVE_ACTIVITY_PLAYER_MUTATION = `
+ mutation SaveActivityPlayer($input: ActivityPlayerInput!) {
+ saveActivityPlayer(input: $input) {
+ id
+ playerId
+ activityId
+ signupTime
+ state
+ stateName
+ }
+ }
+`
+
+const DELETE_ACTIVITY_PLAYER_MUTATION = `
+ mutation DeleteActivityPlayer($id: ID!) {
+ deleteActivityPlayer(id: $id)
+ }
+`
+
+// API鍑芥暟
+export const getActivityPlayers = async (activityId, page = 0, size = 10, name = '') => {
+ if (USE_MOCK_DATA) {
+ return mockActivityPlayers
+ }
+
+ try {
+ const data = await graphqlRequest(GET_ACTIVITY_PLAYERS_QUERY, { activityId, page, size, name })
+ return data.activityPlayers
+ } catch (error) {
+ throw new Error(error.message || '鑾峰彇姣旇禌鎶ュ悕鍒楄〃澶辫触')
+ }
+}
+
+export const getActivityPlayer = async (id) => {
+ if (USE_MOCK_DATA) {
+ return mockActivityPlayerDetail
+ }
+
+ try {
+ const data = await graphqlRequest(GET_ACTIVITY_PLAYER_QUERY, { id })
+ return data.activityPlayer
+ } catch (error) {
+ throw new Error(error.message || '鑾峰彇姣旇禌鎶ュ悕璇︽儏澶辫触')
+ }
+}
+
+export const saveActivityPlayer = async (activityPlayerData) => {
+ if (USE_MOCK_DATA) {
+ return { ...activityPlayerData, id: Date.now().toString() }
+ }
+
+ try {
+ const data = await graphqlRequest(SAVE_ACTIVITY_PLAYER_MUTATION, { input: activityPlayerData })
+ return data.saveActivityPlayer
+ } catch (error) {
+ throw new Error(error.message || '淇濆瓨姣旇禌鎶ュ悕澶辫触')
+ }
+}
+
+export const deleteActivityPlayer = async (id) => {
+ if (USE_MOCK_DATA) {
+ return true
+ }
+
+ try {
+ const data = await graphqlRequest(DELETE_ACTIVITY_PLAYER_MUTATION, { id })
+ return data.deleteActivityPlayer
+ } catch (error) {
+ throw new Error(error.message || '鍒犻櫎姣旇禌鎶ュ悕澶辫触')
+ }
}
const GET_ACTIVITY_PLAYER_DETAIL = `
@@ -40,12 +160,21 @@
description
avatarUrl
}
+ regionInfo {
+ id
+ name
+ fullPath
+ }
activityName
+ projectName
description
+ feedback
+ state
submissionFiles {
id
name
url
+ thumbUrl
fileExt
fileSize
mediaType
@@ -170,10 +299,10 @@
const GET_CURRENT_JUDGE_INFO = `
query GetCurrentJudgeInfo {
currentJudgeInfo {
- id
- name
- phone
- description
+ judgeId
+ judgeName
+ title
+ company
}
}
`
@@ -188,4 +317,44 @@
}))
}
return graphqlRequest(GET_CURRENT_JUDGE_INFO)
+}
+
+// 瀹℃牳鐩稿叧mutations
+const APPROVE_ACTIVITY_PLAYER = `
+ mutation ApproveActivityPlayer($activityPlayerId: ID!, $feedback: String) {
+ approveActivityPlayer(activityPlayerId: $activityPlayerId, feedback: $feedback)
+ }
+`
+
+const REJECT_ACTIVITY_PLAYER = `
+ mutation RejectActivityPlayer($activityPlayerId: ID!, $feedback: String!) {
+ rejectActivityPlayer(activityPlayerId: $activityPlayerId, feedback: $feedback)
+ }
+`
+
+const UPDATE_PLAYER_FEEDBACK = `
+ mutation UpdatePlayerFeedback($activityPlayerId: ID!, $feedback: String!) {
+ updatePlayerFeedback(activityPlayerId: $activityPlayerId, feedback: $feedback)
+ }
+`
+
+/**
+ * 瀹℃牳閫氳繃
+ */
+export function approveActivityPlayer(activityPlayerId, feedback = '') {
+ return graphqlRequest(APPROVE_ACTIVITY_PLAYER, { activityPlayerId, feedback })
+}
+
+/**
+ * 瀹℃牳椹冲洖
+ */
+export function rejectActivityPlayer(activityPlayerId, feedback) {
+ return graphqlRequest(REJECT_ACTIVITY_PLAYER, { activityPlayerId, feedback })
+}
+
+/**
+ * 鏇存柊瀹℃牳鎰忚
+ */
+export function updatePlayerFeedback(activityPlayerId, feedback) {
+ return graphqlRequest(UPDATE_PLAYER_FEEDBACK, { activityPlayerId, feedback })
}
\ No newline at end of file
--
Gitblit v1.8.0