lrj
3 天以前 6d519474e44855682043d3c40db2c86a6822caca
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
$headers = @{
    "Content-Type" = "application/json"
}
 
# 测试1: 创建简单比赛(不包含评委)
$body1 = @{
    query = 'mutation { saveActivity(input: { name: "Test Competition", description: "Test Description", signupDeadline: "2024-12-31T23:59:59", ratingSchemeId: 1, pid: 0 }) { id name description pid } }'
} | ConvertTo-Json
 
Write-Host "创建简单比赛测试..."
$response1 = Invoke-RestMethod -Uri "http://localhost:8080/api/graphql" -Method POST -Body $body1 -Headers $headers
Write-Host "响应结果:"
$response1 | ConvertTo-Json -Depth 10
 
if ($response1.data -and $response1.data.saveActivity) {
    $competitionId = $response1.data.saveActivity.id
    Write-Host "比赛创建成功,ID: $competitionId"
    
    # 测试2: 读取创建的比赛
    $body2 = @{
        query = "query { activity(id: $competitionId) { id name description pid } }"
    } | ConvertTo-Json
    
    Write-Host "读取比赛测试..."
    $response2 = Invoke-RestMethod -Uri "http://localhost:8080/api/graphql" -Method POST -Body $body2 -Headers $headers
    Write-Host "读取结果:"
    $response2 | ConvertTo-Json -Depth 10
} else {
    Write-Host "比赛创建失败"
}