修复:/api/aml/sciot/system-status 500 错误
问题
浏览器请求 GET /api/aml/sciot/system-status 后端返回 HTTP 500。
根因
server/routes/aml.js 中 system-status 的 SCIOT 数据库查询([V5] 路由块)直接查询以下表:
prompt_templatessciot_business_promptssciot_item_types
这些表在 sciot_import.db 中不一定存在(取决于 sciot 的数据导入/初始化状态)。当表不存在时,sql.js 抛出 SQL 错误且未被捕获,导致请求返回 500。
修复内容
在 server/routes/aml.js 中对三个脆弱查询加 try-catch 兜底:
- L316
prompt_templates查询 → 表不存在时prompts = [] - L330
sciot_business_promptsCOUNT 查询 → 表不存在时bizPromptTotal = 0 - L356
sciot_item_typesCOUNT 查询 → 表不存在时totalItemTypes = 0
已验证
- 语法检查通过:
node --check server/routes/aml.js - 降级逻辑:表不存在时返回
prompts: { total: 0, business: 0 }、totalItemTypes: 0
未修复(前端 404)
:3006/api/aml/sciot/system-status:1 Failed to load resource: the server responded with a status of 404 (Not Found)
→ 这是前端静态资源请求(大概率是 JS chunk 或图片),属于前端构建/部署问题,不在后端代码范围内。
需要重新构建前端并部署 dist/ 目录。
BossAgents