verify-session-fixes.ps1 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # Verify all session fixes: channel-accounts, qdrant menu, sales-corpus, industry labels
  2. param(
  3. [string]$TenantDb = "fs_tenant_cs1",
  4. [string]$CompanyApi = "http://127.0.0.1:8006",
  5. [string]$AdminApi = "http://127.0.0.1:8004"
  6. )
  7. $ErrorActionPreference = "Continue"
  8. $pass = 0
  9. $fail = 0
  10. $warn = 0
  11. function Report-Ok($msg) { Write-Host "[PASS] $msg" -ForegroundColor Green; $script:pass++ }
  12. function Report-Fail($msg) { Write-Host "[FAIL] $msg" -ForegroundColor Red; $script:fail++ }
  13. function Report-Warn($msg) { Write-Host "[WARN] $msg" -ForegroundColor Yellow; $script:warn++ }
  14. function Test-HttpNot404 {
  15. param([string]$Base, [string]$Path, [string]$Label)
  16. $uri = "$($Base.TrimEnd('/'))$Path"
  17. try {
  18. $r = Invoke-WebRequest -Uri $uri -UseBasicParsing -TimeoutSec 10
  19. $code = [int]$r.StatusCode
  20. } catch {
  21. $resp = $_.Exception.Response
  22. if ($resp) { $code = [int]$resp.StatusCode } else { $code = 0 }
  23. }
  24. if ($code -eq 404) {
  25. Report-Fail "$Label -> HTTP 404 ($uri)"
  26. } elseif ($code -ge 200 -and $code -lt 500) {
  27. Report-Ok "$Label -> HTTP $code (endpoint registered)"
  28. } else {
  29. Report-Warn "$Label -> HTTP $code"
  30. }
  31. }
  32. Write-Host "=== Session Fixes Verification ===" -ForegroundColor Cyan
  33. # --- API endpoints (401/200 OK, 404 FAIL) ---
  34. Write-Host "`n--- Backend API routes ---" -ForegroundColor Cyan
  35. $companyPaths = @(
  36. @{ Path = "/workflow/lobster-exec/lookup/channel-accounts?channelType=QW"; Label = "实例监控-渠道账号(company)" },
  37. @{ Path = "/workflow/lobster/sales-corpus/tasks?page=1&size=10"; Label = "销冠语料-任务列表(company)" },
  38. @{ Path = "/workflow/lobster/sales-corpus/scenarios"; Label = "销冠语料-场景(company)" },
  39. @{ Path = "/workflow/tagBinding/tag-binding/data-scope"; Label = "数据范围(已移除UI,接口仍可用)" }
  40. )
  41. foreach ($p in $companyPaths) {
  42. Test-HttpNot404 -Base $CompanyApi -Path $p.Path -Label $p.Label
  43. }
  44. $adminPaths = @(
  45. @{ Path = "/workflow/lobster-exec/lookup/channel-accounts?channelType=QW"; Label = "实例监控-渠道账号(admin)" },
  46. @{ Path = "/workflow/lobster/sales-corpus/tasks?page=1&size=10"; Label = "销冠语料-任务列表(admin)" }
  47. )
  48. foreach ($p in $adminPaths) {
  49. Test-HttpNot404 -Base $AdminApi -Path $p.Path -Label $p.Label
  50. }
  51. # --- DB: menus + sales corpus table ---
  52. Write-Host "`n--- Tenant DB ($TenantDb) ---" -ForegroundColor Cyan
  53. node -e @"
  54. const mysql = require('mysql2/promise');
  55. (async () => {
  56. const c = await mysql.createConnection({
  57. host: 'cq-cdb-8fjmemkb.sql.tencentcdb.com', port: 27220,
  58. user: 'root', password: 'Ylrz_1q2w3e4r5t6y',
  59. database: '$TenantDb', charset: 'utf8mb4'
  60. });
  61. const checks = [];
  62. const [qdrantSys] = await c.query('SELECT menu_id,menu_name,path,visible FROM sys_menu WHERE menu_id=29951');
  63. const [qdrantCm] = await c.query('SELECT menu_id,menu_name,path FROM company_menu WHERE menu_id=29951');
  64. checks.push(['向量知识库 sys_menu', qdrantSys.length === 1 && qdrantSys[0].path === 'qdrant']);
  65. checks.push(['向量知识库 company_menu', qdrantCm.length >= 1]);
  66. const [srm] = await c.query('SELECT COUNT(*) cnt FROM sys_role_menu WHERE menu_id=29951');
  67. const [crm] = await c.query('SELECT COUNT(*) cnt FROM company_role_menu WHERE menu_id=29951');
  68. checks.push(['向量知识库角色授权 sys', srm[0].cnt > 0]);
  69. checks.push(['向量知识库角色授权 company', crm[0].cnt > 0]);
  70. const [tbl] = await c.query(`SELECT COUNT(*) cnt FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='lobster_sales_corpus_task'`);
  71. checks.push(['销冠语料任务表', tbl[0].cnt === 1]);
  72. const [col] = await c.query(`SELECT COUNT(*) cnt FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='lobster_sales_corpus' AND COLUMN_NAME='task_id'`);
  73. checks.push(['语料 task_id 字段', col[0].cnt === 1]);
  74. for (const [name, ok] of checks) {
  75. console.log((ok ? 'PASS' : 'FAIL') + '|' + name);
  76. }
  77. await c.end();
  78. })().catch(e => { console.log('FAIL|DB:' + e.message); process.exit(1); });
  79. "@ 2>&1 | ForEach-Object {
  80. if ($_ -match '^(PASS|FAIL)\|(.+)$') {
  81. if ($matches[1] -eq 'PASS') { Report-Ok $matches[2] } else { Report-Fail $matches[2] }
  82. } else { Write-Host $_ }
  83. }
  84. # --- Frontend code checks ---
  85. Write-Host "`n--- Frontend code ---" -ForegroundColor Cyan
  86. $root = "d:\ylrz_saas_new"
  87. $feChecks = @(
  88. @{ File = "$root\saas-companyui\src\views\lobster\sales-corpus\index.vue"; Must = "formatIndustryType|getIndustryTypeLabel"; MustNot = "scopeLabel|loadDataScope|数据范围"; Name = "companyui 销冠语料(无数据范围+对齐)" },
  89. @{ File = "$root\saas-companyui\src\views\company\workflowLobster\index.vue"; Must = "formatIndustryType"; Name = "companyui 行业类型中文" },
  90. @{ File = "$root\saas-companyui\src\utils\lobster\industryOptions.js"; Must = "getIndustryTypeLabel"; Name = "companyui industryOptions 工具" },
  91. @{ File = "$root\saas-mgnui\src\views\company\workflowLobster\index.vue"; Must = "formatIndustryType"; Name = "mgnui 行业类型中文" },
  92. @{ File = "$root\saas-companyui\src\views\lobster\qdrant\index.vue"; Must = ""; Name = "companyui 向量知识库页面" }
  93. )
  94. foreach ($c in $feChecks) {
  95. if (-not (Test-Path $c.File)) {
  96. Report-Fail "$($c.Name) - file missing"
  97. continue
  98. }
  99. $content = Get-Content $c.File -Raw -ErrorAction SilentlyContinue
  100. $ok = $true
  101. if ($c.Must) {
  102. foreach ($m in ($c.Must -split '\|')) {
  103. if ($content -notmatch [regex]::Escape($m) -and $content -notmatch $m) { $ok = $false; break }
  104. }
  105. }
  106. if ($c.MustNot) {
  107. foreach ($m in ($c.MustNot -split '\|')) {
  108. if ($content -match $m) { $ok = $false; break }
  109. }
  110. }
  111. if ($c.Name -match "向量知识库页面") {
  112. if (Test-Path $c.File) { Report-Ok $c.Name } else { Report-Fail $c.Name }
  113. } elseif ($ok) { Report-Ok $c.Name } else { Report-Fail $c.Name }
  114. }
  115. # sales-corpus align styles
  116. $corpUi = Get-Content "$root\saas-companyui\src\views\lobster\sales-corpus\index.vue" -Raw
  117. if ($corpUi -match 'width:\s*100%' -and $corpUi -match 'margin-left:\s*0') {
  118. Report-Ok "companyui 查询区 width 100% 对齐"
  119. } else {
  120. Report-Fail "companyui 查询区对齐样式"
  121. }
  122. Write-Host "`n=== Summary: PASS=$pass FAIL=$fail WARN=$warn ===" -ForegroundColor $(if ($fail -eq 0) { "Green" } else { "Red" })
  123. if ($fail -gt 0) { exit 1 }