$body = '{"tenantCode":"T202605253515","username":"admin","password":"admin123"}'
$r = Invoke-WebRequest -Uri 'http://localhost:8006/login' -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
$j = $r.Content | ConvertFrom-Json
$token = $j.token
Write-Host "Login: code=$($j.code) token_len=$($token.Length)"

# Test his endpoints  
$tests = @('/his/healthTongue/list', '/his/healthRecord/list', '/his/doctor/list', '/course/courseDomainName/list', '/qw/tag/list', '/billing/wallet/list')
foreach ($p in $tests) {
    try {
        $r2 = Invoke-WebRequest -Uri "http://localhost:8006$p" -Method Get -Headers @{Authorization="Bearer $token"} -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
        $j2 = $r2.Content | ConvertFrom-Json
        Write-Host "$p => code=$($j2.code)"
    } catch {
        $sc = 0
        if ($_.Exception.Response) { $sc = [int]$_.Exception.Response.StatusCode }
        Write-Host "$p => $sc ERROR"
    }
}
