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.
60 lines
2.9 KiB
60 lines
2.9 KiB
|
3 weeks ago
|
# 前端契约回归:模拟 demo 页面加载时的全部自动请求,验证后端链路
|
||
|
|
$base = "http://127.0.0.1:8081"
|
||
|
|
$userId = "739564171091247104"
|
||
|
|
$out = @()
|
||
|
|
|
||
|
|
function Check($label, $resp, $extra) {
|
||
|
|
$ok = $resp.success
|
||
|
|
$line = "[{0}] {1} code={2} ok={3} {4}" -f $(if($ok){"OK"}else{"FAIL"}), $label, $resp.code, $ok, $extra
|
||
|
|
$script:out += $line
|
||
|
|
Write-Output $line
|
||
|
|
}
|
||
|
|
|
||
|
|
# 0. 登录
|
||
|
|
$tok = (Invoke-RestMethod -Method Get -Uri "$base/api/auth/debug/token?userId=$userId" -TimeoutSec 30).data
|
||
|
|
$h = @{ Authorization = "Bearer $tok" }
|
||
|
|
$out += "[token] len=$($tok.Length)"
|
||
|
|
|
||
|
|
# 1. 省份
|
||
|
|
$r1 = Invoke-RestMethod -Method Get -Uri "$base/api/rule/region/level?level=1" -Headers $h -TimeoutSec 30
|
||
|
|
Check "region/level(level=1)" $r1 ("省数=" + $r1.data.Count)
|
||
|
|
$firstProvId = $r1.data[0].id
|
||
|
|
|
||
|
|
# 2. 市级联
|
||
|
|
$r2 = Invoke-RestMethod -Method Get -Uri "$base/api/rule/region/list?parentId=$firstProvId" -Headers $h -TimeoutSec 30
|
||
|
|
Check "region/list(parentId=$firstProvId)" $r2 ("市数=" + $r2.data.Count)
|
||
|
|
|
||
|
|
# 3. 字典4组
|
||
|
|
foreach ($g in @("lead_source","brand","product","scene")) {
|
||
|
|
$rd = Invoke-RestMethod -Method Get -Uri "$base/api/dict/item/enabled-list?groupCode=$g" -Headers $h -TimeoutSec 30
|
||
|
|
Check "dict/enabled-list($g)" $rd ("项数=" + $rd.data.Count)
|
||
|
|
}
|
||
|
|
|
||
|
|
# 4. 公海池
|
||
|
|
$rp = Invoke-RestMethod -Method Post -Uri "$base/api/rule/pool/page" -Headers $h -ContentType "application/x-www-form-urlencoded" -Body "current=1&size=50" -TimeoutSec 30
|
||
|
|
Check "rule/pool/page" $rp ("total=" + $rp.data.total + " 池数=" + $rp.data.content.Count)
|
||
|
|
|
||
|
|
# 5. 部门树
|
||
|
|
$rd2 = Invoke-RestMethod -Method Get -Uri "$base/api/system/depts/tree" -Headers $h -TimeoutSec 30
|
||
|
|
$cnt = 0; function Walk($n){ $script:cnt++; if($n.children){ $n.children | ForEach-Object { Walk $_ } } }
|
||
|
|
$rd2.data | ForEach-Object { Walk $_ }
|
||
|
|
Check "system/depts/tree" $rd2 ("节点数=" + $cnt)
|
||
|
|
|
||
|
|
# 6. 用户列表
|
||
|
|
$ru = Invoke-RestMethod -Method Post -Uri "$base/api/system/users/page" -Headers $h -ContentType "application/x-www-form-urlencoded" -Body "current=1&size=5" -TimeoutSec 30
|
||
|
|
Check "system/users/page" $ru ("total=" + $ru.data.total + " 本页=" + $ru.data.content.Count)
|
||
|
|
|
||
|
|
# 7. 线索列表(MANAGE)
|
||
|
|
$rl = Invoke-RestMethod -Method Post -Uri "$base/api/lead/page" -Headers $h -ContentType "application/x-www-form-urlencoded" -Body "current=1&size=10&viewType=MANAGE" -TimeoutSec 30
|
||
|
|
Check "lead/page(MANAGE)" $rl ("total=" + $rl.data.total + " 本页=" + $rl.data.content.Count)
|
||
|
|
|
||
|
|
# 8. 线索统计三视图
|
||
|
|
foreach ($v in @("MANAGE","PUBLIC_POOL","MY_LEAD")) {
|
||
|
|
$rs = Invoke-RestMethod -Method Post -Uri "$base/api/lead/stats" -Headers $h -ContentType "application/x-www-form-urlencoded" -Body "viewType=$v" -TimeoutSec 30
|
||
|
|
Check "lead/stats($v)" $rs ("data=" + ($rs.data | ConvertTo-Json -Compress))
|
||
|
|
}
|
||
|
|
|
||
|
|
$pass = ($out | Where-Object { $_ -like "[FAIL]*" }).Count
|
||
|
|
$out += "==== SUMMARY: FAIL=$pass / total=$($out.Count-1) ===="
|
||
|
|
$out | Out-File -Encoding utf8 "d:\code\crm-backend-matt\tmp\frontend-verify-out.txt"
|