# Get all registered request mappings from the running fs-company instance
$companyUrl = "http://localhost:8006"

# Login
$loginBody = '{"tenantCode":"T202605253515","username":"admin","password":"admin123"}'
$loginResp = Invoke-WebRequest -Uri "$companyUrl/login" -Method POST -ContentType "application/json" -Body $loginBody -UseBasicParsing
$loginJson = $loginResp.Content | ConvertFrom-Json
$token = $loginJson.token
Write-Host "Token OK"

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

# Try to get mappings from actuator or error endpoint
# Spring Boot 2.x exposes /actuator/mappings if actuator is enabled
Write-Host "`n=== Try /actuator/mappings ==="
try {
    $mappingsResp = Invoke-WebRequest -Uri "$companyUrl/actuator/mappings" -Method GET -Headers $headers -UseBasicParsing -TimeoutSec 5
    Write-Host "Actuator mappings available!"
    $mappingsResp.Content | Out-File -FilePath "d:\ylrz\saasadminui\mappings.json" -Encoding UTF8
} catch {
    Write-Host "Actuator not available: $($_.Exception.Message)"
}

# Alternative: check log file for registered mappings
Write-Host "`n=== Check fs-company log ==="
$logPath = "d:\ylrz\ylrz_saas_his_scrm\fs-company\target\fs-company.jar"
# Check the startup log - look for last running instance
Write-Host "Looking for startup log with mapping info..."
