fix(ai): 审计问题修复 — 错误映射/性能/SSE/依赖规范化
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- C3: handler 中 .map_err(AppError::Internal) 改为 ? 操作符,
  利用 From<AiError> for AppError 实现正确的 HTTP 状态码映射
- H1: AiState 预构建在 AppState 初始化时,避免每次请求重建
  ClaudeProvider/AnalysisService/PromptService/UsageService
- H3: stream_analyze 的 user_id 参数传递到 created_by/updated_by
- H5: SSE 事件添加 .event("chunk"/"error"/"done") 类型字段
- L3: erp-ai Cargo.toml 依赖改用 workspace 引用
  (reqwest/handlebars/sha2/hex)
- 修复 erp-health 编译错误: points_handler 缺少 ColumnTrait 导入,
  points_service 版本字段部分移动问题
This commit is contained in:
iven
2026-04-25 16:53:01 +08:00
parent 4ab67ba559
commit 9901d5ce49
5 changed files with 49 additions and 51 deletions

View File

@@ -32,7 +32,7 @@ impl AnalysisService {
pub async fn stream_analyze(
&self,
tenant_id: Uuid,
_user_id: Uuid,
user_id: Uuid,
patient_id: Uuid,
analysis_type: AnalysisType,
source_ref: String,
@@ -58,6 +58,7 @@ impl AnalysisService {
self.create_analysis_record(
analysis_id,
tenant_id,
user_id,
patient_id,
analysis_type.as_str(),
&source_ref,
@@ -145,6 +146,7 @@ impl AnalysisService {
&self,
id: Uuid,
tenant_id: Uuid,
user_id: Uuid,
patient_id: Uuid,
analysis_type: &str,
source_ref: &str,
@@ -170,8 +172,8 @@ impl AnalysisService {
error_message: Set(None),
created_at: Set(now),
updated_at: Set(now),
created_by: Set(None),
updated_by: Set(None),
created_by: Set(Some(user_id)),
updated_by: Set(Some(user_id)),
deleted_at: Set(None),
version_lock: Set(1),
};