$loginBody = '{"tenantCode":"T202605253515","username":"admin","password":"admin123"}'
$loginResp = Invoke-RestMethod -Uri 'http://localhost:8006/company/login' -Method POST -ContentType 'application/json' -Body $loginBody
$token = $loginResp.token
Write-Host "Token OK"

$headers = @{ Authorization = "Bearer $token" }

# Test getRouters
$resp = Invoke-RestMethod -Uri 'http://localhost:8006/getRouters' -Method GET -Headers $headers
Write-Host "getRouters code: $($resp.code)"
Write-Host "getRouters msg: $($resp.msg)"
Write-Host "Data count: $($resp.data.Count)"

if ($resp.data -and $resp.data.Count -gt 0) {
    $resp.data | ForEach-Object { Write-Host "  Menu: $($_.name) path=$($_.path) component=$($_.component)" }
} else {
    Write-Host "No menu data returned!"
}

# Also try system/menu/list
Write-Host "`n=== Try system/menu/list ==="
try {
    $menuResp = Invoke-RestMethod -Uri 'http://localhost:8006/system/menu/list' -Method GET -Headers $headers
    Write-Host "Menu list code: $($menuResp.code)"
    Write-Host "Menu total: $($menuResp.total)"
    if ($menuResp.total -gt 0) {
        $menuResp.rows | Select-Object -First 5 | ForEach-Object { Write-Host "  Menu: $($_.menuName) perms=$($_.perms) path=$($_.path)" }
    }
} catch {
    Write-Host "Menu list error: $($_.Exception.Message)"
}
