$ErrorActionPreference = "SilentlyContinue"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$body = '{"username":"admin","password":"admin123","tenantCode":"T202605253515"}'
$resp = Invoke-WebRequest -Uri 'http://localhost:8006/login' -Method POST -ContentType 'application/json' -Body $body -UseBasicParsing -TimeoutSec 10
$json = $resp.Content | ConvertFrom-Json
$token = $json.token
$headers = @{ 'Authorization' = "Bearer $token" }

# Quick test
$tests = @('/his/store/list', '/his/doctor/list', '/his/user/list', '/course/courseDomainName/list', '/crm/customer/list', '/live/coupon/list', '/qw/externalContact/list', '/company/company/list')
foreach ($url in $tests) {
    try {
        $r = Invoke-WebRequest -Uri "http://localhost:8006$url" -Method GET -Headers $headers -UseBasicParsing -TimeoutSec 5
        Write-Output "200|GET|$url"
    } catch {
        $err = $_.Exception.Message
        if ($err -match '404') { Write-Output "404|GET|$url" }
        else { if ($err -match '(\d{3})') { $c = $Matches[1] } else { $c = 'ERR' }; Write-Output "$c|GET|$url" }
    }
}
