feat(health,ai): 后端服务优化 + 媒体文件处理

- erp-health: article/banner/consultation/media 服务层优化
- erp-ai: analysis/insight/prompt 服务增强
- erp-auth: auth/role/token 服务改进
- erp-workflow: executor 执行引擎修复
- erp-plugin: 服务层改进
- 新增媒体上传文件样例
This commit is contained in:
iven
2026-05-13 23:28:57 +08:00
parent e4e5ef04d4
commit 212c08b7ae
30 changed files with 320 additions and 3 deletions

View File

@@ -29,6 +29,13 @@ pub struct MessageListParams {
pub after_id: Option<Uuid>,
}
#[derive(Debug, Deserialize, IntoParams)]
pub struct PollMessagesParams {
pub after_id: Option<Uuid>,
/// 超时秒数,默认 25最大 30
pub timeout: Option<u64>,
}
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
pub struct CloseSessionReq {
pub version: i32,
@@ -129,6 +136,30 @@ where
Ok(Json(ApiResponse::ok(result)))
}
/// 长轮询咨询消息 — 有新消息立即返回,否则挂起等待(最多 timeout 秒)。
pub async fn poll_messages<S>(
State(state): State<HealthState>,
Extension(ctx): Extension<TenantContext>,
Path(session_id): Path<Uuid>,
Query(params): Query<PollMessagesParams>,
) -> Result<Json<ApiResponse<Vec<MessageResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
require_permission(&ctx, "health.consultation.list")?;
let timeout_secs = params.timeout.unwrap_or(25).min(30);
let result = consultation_service::poll_new_messages(
&state,
ctx.tenant_id,
session_id,
params.after_id,
timeout_secs,
)
.await?;
Ok(Json(ApiResponse::ok(result)))
}
pub async fn close_session<S>(
State(state): State<HealthState>,
Extension(ctx): Extension<TenantContext>,