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.

43 lines
2.2 KiB

1 week ago
$ErrorActionPreference = 'Continue'
[Console]::OutputEncoding = [Text.Encoding]::UTF8
$base = 'http://localhost:8080'
$outDir = '.scratch\opportunity-e2e\env-raw'
function Save-Json($name, $obj) {
$obj | ConvertTo-Json -Depth 8 | Out-File -FilePath (Join-Path $outDir ("{0}.json" -f $name)) -Encoding utf8
Write-Host ("saved {0}" -f $name)
}
$uid = '739564171091247104'
$r = Invoke-RestMethod -Uri ("$base/api/auth/debug/token?userId=$uid")
$token = if ($r.data -is [string]) { $r.data } else { $r.data.token }
$h = @{ Authorization = "Bearer $token" }
# 1. 商机状态分布:statusIn 逐值轮询(MINE + MANAGE 各一遍)
foreach ($v in @('MINE','MANAGE')) {
foreach ($s in 1..5) {
$p = Invoke-RestMethod -Uri "$base/api/opportunity/page" -Method Post -Headers $h -Body ("viewType={0}&current=1&size=500&statusIn={1}" -f $v, $s) -ContentType 'application/x-www-form-urlencoded'
Write-Host ("{0} statusIn={1}: total={2}" -f $v, $s, $p.data.total)
if ($p.data.total -gt 0) { Save-Json ("opp-{0}-s{1}" -f $v, $s) $p }
}
}
# 2. 全量商机(current/size 正确参数)
$p = Invoke-RestMethod -Uri "$base/api/opportunity/page" -Method Post -Headers $h -Body "viewType=MANAGE&current=1&size=500" -ContentType 'application/x-www-form-urlencoded'
Save-Json 'opp-all' $p
Write-Host ("opp-all total={0} n={1}" -f $p.data.total, $p.data.content.Count)
# 3. 用户:按部门翻(营销中心 / 特战团队 / 华南销售部 seed / 运营中心)
foreach ($d in @(@('yinxiao','744841295071019008'), @('tezhan','744841308564094976'), @('huannan-seed','744700334353416192'), @('yunying','744841296513859584'))) {
$p = Invoke-RestMethod -Uri "$base/api/system/users/page" -Method Post -Headers $h -Body ("current=1&size=50&deptId={1}&employmentStatus=active" -f $d[0], $d[1]) -ContentType 'application/x-www-form-urlencoded'
Save-Json ("users-{0}" -f $d[0]) $p
Write-Host ("users {0}: total={1}" -f $d[0], $p.data.total)
}
# 4. RECENT 视图全量(看最近访问样例)
$p = Invoke-RestMethod -Uri "$base/api/opportunity/page" -Method Post -Headers $h -Body "viewType=RECENT&current=1&size=50" -ContentType 'application/x-www-form-urlencoded'
Save-Json 'opp-recent' $p
Write-Host ("recent total={0}" -f $p.data.total)
Write-Host 'DONE2'