// 直接查询特定参赛人的详情数据 const axios = require('axios'); async function checkPlayerDetail(playerId) { const detailQuery = ` query GetActivityPlayerDetail($id: ID!) { activityPlayerDetail(id: $id) { id projectName playerInfo { id name gender education birthday } regionInfo { name } } } `; try { const detailResponse = await axios.post('http://localhost:8080/api/graphql', { query: detailQuery, variables: { id: playerId } }, { headers: { 'Content-Type': 'application/json' } }); if (detailResponse.data.errors) { console.log(' 详情查询错误:', detailResponse.data.errors); return; } const detail = detailResponse.data.data?.activityPlayerDetail; if (!detail) { console.log(' 未找到详情数据'); return; } console.log(' 详情数据:'); console.log(` 姓名: ${detail.playerInfo.name}`); console.log(` 性别 (原始): ${detail.playerInfo.gender} (${typeof detail.playerInfo.gender})`); console.log(` 学历 (原始): "${detail.playerInfo.education}" (${typeof detail.playerInfo.education})`); console.log(` 生日: ${detail.playerInfo.birthday}`); console.log(` 地区: ${detail.regionInfo?.name}`); // 测试性别转换逻辑 let genderText = '未填写'; if (detail.playerInfo.gender === 0) genderText = '女'; if (detail.playerInfo.gender === 1) genderText = '男'; console.log(` 性别转换结果: ${genderText}`); // 测试学历处理逻辑 const education = detail.playerInfo.education || ''; console.log(` 学历长度: ${education.length}`); console.log(` 学历处理结果: ${education || '未填写'}`); // 检查问题 if (detail.playerInfo.gender === 1 && genderText === '女') { console.log(` ❌ 性别转换错误: 应该是男,但显示为女`); } if (detail.playerInfo.education && detail.playerInfo.education.trim() && (education || '未填写') === '未填写') { console.log(` ❌ 学历显示错误: 有学历但显示为未填写`); } // 检查当前的getGenderText函数逻辑 console.log(` 当前getGenderText逻辑测试:`); console.log(` gender === 0 ? '女' : gender === 1 ? '男' : '未填写'`); const currentLogic = detail.playerInfo.gender === 0 ? '女' : detail.playerInfo.gender === 1 ? '男' : '未填写'; console.log(` 结果: ${currentLogic}`); } catch (error) { console.log(` 查询详情失败: ${error.message}`); } } async function checkSpecificPlayerData() { try { // 先查询参赛人列表 const listQuery = ` query { activityPlayerApplications(page: 1, size: 20) { content { id playerName projectName phone state } } } `; console.log('=== 查询参赛人列表 ==='); const listResponse = await axios.post('http://localhost:8080/api/graphql', { query: listQuery }, { headers: { 'Content-Type': 'application/json' } }); if (listResponse.data.errors) { console.log('列表查询错误:', listResponse.data.errors); return; } const applications = listResponse.data.data?.activityPlayerApplications?.content || []; if (applications.length === 0) { console.log('没有找到参赛人数据'); return; } console.log(`找到 ${applications.length} 个参赛人,开始查询详情...`); // 查询每个参赛人的详情 for (let i = 0; i < Math.min(applications.length, 10); i++) { const app = applications[i]; console.log(`\n=== 参赛人 ${i + 1} (ID: ${app.id}) ===`); console.log(` 姓名: ${app.playerName}`); console.log(` 项目名: ${app.projectName}`); console.log(` 状态: ${app.state}`); // 查询详情 await checkPlayerDetail(app.id); } } catch (error) { console.error('查询失败:', error.message); } } checkSpecificPlayerData();