$base = "http://localhost:7070/admin"

# 1. Login
$loginBody = Get-Content -Raw "d:\快与慢充电桩\code\haha\docs\login.json"
$login = Invoke-RestMethod -Uri "$base/login" -Method POST -ContentType "application/json" -Body $loginBody
$token = $login.data.token
Write-Host "Login OK, token: $token"

$headers = @{
    "adminAccessToken" = $token
    "Content-Type" = "application/json"
}

# 2. Restore full menu set for admin role (all 11 menus)
$saveBody = '{"roleId":1,"menuIds":[1001,2001,2002,2003,2004,3001,3002,4001,4002,5001,5002]}'
$r = Invoke-RestMethod -Uri "$base/menu/save-role-menus" -Method POST -Headers $headers -Body $saveBody
Write-Host "Restore role menus: code=$($r.code), message=$($r.message)"

# 3. Verify
$body = '{"id":1}'
$r = Invoke-RestMethod -Uri "$base/menu/role-menu-ids" -Method POST -Headers $headers -Body $body
Write-Host "Role 1 menu IDs: $($r.data -join ', ')"
Write-Host "Count: $($r.data.Count)"
