lrj
昨天 9f8395fab13ca4b230a0f7d62636e209745c91d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const axios = require('axios');
 
// 配置
const GRAPHQL_URL = 'http://localhost:8080/api/graphql';
 
// 查询媒体记录的GraphQL查询
const MEDIAS_BY_TARGET_QUERY = `
  query MediasByTarget($targetType: Int!, $targetId: ID!) {
    mediasByTarget(targetType: $targetType, targetId: $targetId) {
      id
      name
      path
      fileExt
      mediaType
      fullUrl
    }
  }
`;
 
async function testMediaQuery() {
  console.log('🔍 测试媒体查询接口...\n');
 
  // 测试查询选手头像媒体记录 (targetType: 1, targetId: 42)
  console.log('1. 查询选手头像媒体记录 (targetType: 1, targetId: 42)...');
  try {
    const response = await axios.post(GRAPHQL_URL, {
      query: MEDIAS_BY_TARGET_QUERY,
      variables: {
        targetType: 1,
        targetId: "42"
      }
    });
    
    console.log('选手头像媒体记录:', JSON.stringify(response.data, null, 2));
  } catch (error) {
    console.error('查询选手头像媒体记录失败:', error.response?.data || error.message);
  }
 
  console.log('\n2. 查询活动报名附件媒体记录 (targetType: 2, targetId: 32)...');
  try {
    const response = await axios.post(GRAPHQL_URL, {
      query: MEDIAS_BY_TARGET_QUERY,
      variables: {
        targetType: 2,
        targetId: "32"
      }
    });
    
    console.log('活动报名附件媒体记录:', JSON.stringify(response.data, null, 2));
  } catch (error) {
    console.error('查询活动报名附件媒体记录失败:', error.response?.data || error.message);
  }
}
 
testMediaQuery().catch(console.error);