You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
2.1 KiB
38 lines
2.1 KiB
$ErrorActionPreference = 'Stop'
|
|
$base = 'http://localhost:8081'
|
|
$token = Get-Content 'e:\code\crm-backend-matt\tmp\dt-token.txt' -Raw
|
|
$headers = @{ Authorization = "Bearer $token" }
|
|
|
|
function PostForm($url, $formStr) {
|
|
return Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body ([System.Text.Encoding]::UTF8.GetBytes($formStr)) -ContentType 'application/x-www-form-urlencoded; charset=utf-8'
|
|
}
|
|
|
|
$kw = [string]::new([char[]](0x5317, 0x4EAC)) # 北京
|
|
$kwNeg = [string]::new([char[]](0x9F9F, 0x5154)) # 龟兔
|
|
|
|
# stats PUBLIC_POOL / MY_LEAD
|
|
$s1 = PostForm "$base/api/lead/stats" 'viewType=PUBLIC_POOL'
|
|
Write-Host "stats PUBLIC_POOL: $($s1.data | ConvertTo-Json -Compress)"
|
|
$s2 = PostForm "$base/api/lead/stats" 'viewType=MY_LEAD'
|
|
Write-Host "stats MY_LEAD: $($s2.data | ConvertTo-Json -Compress)"
|
|
$s3 = PostForm "$base/api/lead/stats" 'viewType=MANAGE'
|
|
Write-Host "stats MANAGE: $($s3.data | ConvertTo-Json -Compress)"
|
|
|
|
# keyword filter
|
|
$p1 = PostForm "$base/api/lead/page" ('viewType=MANAGE&pageNum=1&pageSize=20&keyword=' + [Uri]::EscapeDataString($kw))
|
|
Write-Host "page keyword=Beijing total=$($p1.data.total)"
|
|
foreach ($it in $p1.data.content) { Write-Host (" {0} | {1}/{2} | status={3}" -f $it.id, $it.provinceName, $it.cityName, $it.status) }
|
|
$p2 = PostForm "$base/api/lead/page" ('viewType=MANAGE&pageNum=1&pageSize=20&keyword=' + [Uri]::EscapeDataString($kwNeg))
|
|
Write-Host "page keyword=negative total=$($p2.data.total)"
|
|
$p3 = PostForm "$base/api/lead/page" 'viewType=MANAGE&pageNum=1&pageSize=20&keyword=13800138001'
|
|
Write-Host "page keyword=phone13800138001 total=$($p3.data.total)"
|
|
|
|
# PUBLIC_POOL should only status=2
|
|
$p4 = PostForm "$base/api/lead/page" 'viewType=PUBLIC_POOL&pageNum=1&pageSize=20'
|
|
Write-Host "page PUBLIC_POOL total=$($p4.data.total) statuses=$(($p4.data.content | ForEach-Object { $_.status }) -join ',')"
|
|
|
|
# history opUserName
|
|
$h = Invoke-RestMethod -Uri "$base/api/lead/history?leadId=744700344537186304" -Method Get -Headers $headers
|
|
Write-Host "history count=$($h.data.Count)"
|
|
$h.data | ConvertTo-Json -Depth 3 | Out-File -FilePath 'e:\code\crm-backend-matt\tmp\history-out.json' -Encoding utf8
|
|
Write-Host "DONE"
|
|
|