feat(server): erp-ai 模块集成 — Config/State/路由注册

- 新增 AiConfig 到 AppConfig
- 新增 FromRef<AppState> for AiState
- 注册 AiModule 到 ModuleRegistry
- 合并 AI protected routes
- 修复 sync_module_permissions 只同步 health.% 的 bug

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
iven
2026-04-25 14:01:07 +08:00
parent fada33101c
commit 2e555ca72a
5 changed files with 64 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ pub struct AppConfig {
pub cors: CorsConfig,
pub wechat: WechatConfig,
pub health: HealthConfig,
pub ai: AiConfig,
}
#[derive(Debug, Clone, Deserialize)]
@@ -69,6 +70,18 @@ pub struct HealthConfig {
pub hmac_key: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct AiConfig {
pub default_provider: String,
pub api_key: String,
pub base_url: Option<String>,
pub model: String,
pub max_tokens: u32,
pub temperature: f32,
pub cache_ttl_seconds: u64,
pub rate_limit_patient_daily: u32,
}
impl AppConfig {
pub fn load() -> anyhow::Result<Self> {
let config = config::Config::builder()