test_proxy_final.ps1 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # Test key endpoints through the proxy after vue.config.js fix
  2. $body = '{"tenantCode":"T202605253515","username":"admin","password":"admin123"}'
  3. $loginResp = Invoke-WebRequest -Uri 'http://localhost:80/prod-api/login' -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
  4. $token = ($loginResp.Content | ConvertFrom-Json).token
  5. Write-Host "Login OK, token length: $($token.Length)"
  6. # Test key proxy rewrite rules
  7. $tests = @(
  8. # /store/store/* → /store/*
  9. @{name='store/store→store'; path='/store/store/list'},
  10. @{name='store/storeOrder→store'; path='/store/storeOrder/list'},
  11. @{name='store/storeProduct→store'; path='/store/storeProduct/list'},
  12. # /store/his/* → /his/*
  13. @{name='store/his→his'; path='/store/his/doctor/list'},
  14. # /store/doctor/* → /his/doctor/*
  15. @{name='store/doctor→his/doctor'; path='/store/doctor/list'},
  16. # /store/healthTongue → /his/healthTongue
  17. @{name='store/healthTongue→his'; path='/store/healthTongue/list'},
  18. # /store/inquiryOrder → /his/inquiryOrder
  19. @{name='store/inquiryOrder→his'; path='/store/inquiryOrder/list'},
  20. # /his/fsPatient → /store/patient
  21. @{name='his/fsPatient→store/patient'; path='/his/fsPatient/list'},
  22. @{name='his/fsUser→store/user'; path='/his/fsUser/list'},
  23. @{name='his/fsMaterial→store/material'; path='/his/fsMaterial/list'},
  24. @{name='his/fsCoupon→store/coupon'; path='/his/fsCoupon/list'},
  25. @{name='his/fsDrugReport→store/drugReport'; path='/his/fsDrugReport/list'},
  26. @{name='his/fsStoreOrderOffline→hisStore'; path='/his/fsStoreOrderOffline/list'},
  27. @{name='his/fsStoreOrderAudit→hisStore'; path='/his/fsStoreOrderAudit/list'},
  28. @{name='his/fsStoreStatistics→hisStore'; path='/his/fsStoreStatistics/list'},
  29. @{name='his/fsCollection→store/collection'; path='/his/fsCollection/list'},
  30. @{name='his/fsFirstDiagnosis→his/diagnosis'; path='/his/fsFirstDiagnosis/list'},
  31. # hisStore/collection → store/collection
  32. @{name='hisStore/collection→store'; path='/hisStore/collection/list'},
  33. # /his_store/* → /hisStore/*
  34. @{name='his_store→hisStore'; path='/his_store/store_instant_discount/list'},
  35. # /wx/wxSop → /qwSop/sopUserLogs
  36. @{name='wx/wxSop→qwSop'; path='/wx/wxSop/list'},
  37. @{name='wx/wxSopUser→qwSop'; path='/wx/wxSopUser/list'},
  38. # /wxSop/sopUserLogsWx → /qwSop/sopUserLogs
  39. @{name='wxSop/sopUserLogsWx→qwSop'; path='/wxSop/sopUserLogsWx/list'},
  40. # /fast_gpt/* → /fastGpt/*
  41. @{name='fast_gpt→fastGpt'; path='/fast_gpt/read_package/list'},
  42. # /admin/medical → fs-admin(8003)
  43. @{name='admin/medical→admin'; path='/admin/medical/list'},
  44. # /company/company → /company
  45. @{name='company/company→company'; path='/company/company/list'},
  46. # /company/companyTag → /companyTag
  47. @{name='company/companyTag→companyTag'; path='/company/companyTag/list'},
  48. # /company/companyUser → /companyUser
  49. @{name='company/companyUser→companyUser'; path='/company/companyUser/list'},
  50. # /company/companyVoice → /companyVoice
  51. @{name='company/companyVoice→companyVoice'; path='/company/companyVoice/list'},
  52. # /company/easyCall → /easyCall
  53. @{name='company/easyCall→easyCall'; path='/company/easyCall/gateway/list'},
  54. # /sop/companySopRole → /companySopRole
  55. @{name='sop/companySopRole→companySopRole'; path='/sop/companySopRole/list'},
  56. # Direct paths that should work
  57. @{name='his:healthTongue'; path='/his/healthTongue/list'},
  58. @{name='his:healthRecord'; path='/his/healthRecord/list'},
  59. @{name='his:drugReport'; path='/his/drugReport/list'},
  60. @{name='his:exportTask'; path='/his/exportTask/list'},
  61. @{name='his:inquiryOrder'; path='/his/inquiryOrder/list'},
  62. @{name='his:doctor'; path='/his/doctor/list'},
  63. @{name='his:prescription'; path='/his/prescription/list'},
  64. @{name='course:courseDomainName'; path='/course/courseDomainName/list'},
  65. @{name='course:courseQuestionBank'; path='/course/courseQuestionBank/list'},
  66. @{name='billing:wallet'; path='/billing/wallet/list'},
  67. @{name='billing:bill'; path='/billing/bill/list'},
  68. @{name='transfer:fsTransfer'; path='/transfer/fsTransfer/list'},
  69. @{name='chat:chatMsg'; path='/chat/chatMsg/list'},
  70. @{name='qw:tag'; path='/qw/tag/list'},
  71. @{name='qw:sop'; path='/qw/sop/list'},
  72. @{name='qw:material'; path='/qw/material/list'},
  73. @{name='qw:user'; path='/qw/user/list'},
  74. @{name='crm:customer'; path='/crm/customer/list'},
  75. @{name='index:statistics'; path='/index/statistics/rechargeComsumption'},
  76. # system → fs-admin
  77. @{name='system:user→admin'; path='/system/user/list'},
  78. @{name='system:role→admin'; path='/system/role/list'},
  79. @{name='system:menu→admin'; path='/system/menu/list'}
  80. )
  81. $ok = 0; $fail = 0; $err = 0
  82. foreach ($t in $tests) {
  83. $url = "http://localhost:80/prod-api$($t.path)"
  84. try {
  85. $r = Invoke-WebRequest -Uri $url -Method Get -Headers @{Authorization="Bearer $token"} -UseBasicParsing -TimeoutSec 10 -ErrorAction Stop
  86. $content = $r.Content | ConvertFrom-Json
  87. if ($content.code -eq 200) {
  88. Write-Host "OK $($t.name)"
  89. $ok++
  90. } elseif ($content.code -eq 500) {
  91. $msg = $content.msg
  92. if ($msg.Length -gt 60) { $msg = $msg.Substring(0,60) }
  93. Write-Host "ERR $($t.name) => code=500 msg=$msg"
  94. $err++
  95. } else {
  96. $msg = $content.msg
  97. if ($msg -and $msg.Length -gt 60) { $msg = $msg.Substring(0,60) }
  98. Write-Host "WRN $($t.name) => code=$($content.code) msg=$msg"
  99. $fail++
  100. }
  101. } catch {
  102. $statusCode = 0
  103. if ($_.Exception.Response) { $statusCode = [int]$_.Exception.Response.StatusCode }
  104. Write-Host "$statusCode $($t.name) => ERROR"
  105. $fail++
  106. }
  107. }
  108. Write-Host "`n=== SUMMARY: OK=$ok, ERR(500)=$err, FAIL=$fail ==="