refactor(backend): update supporting modules for database compatibility

- Add DatabaseError variant to AppError enum
- Update provider module to support database-backed operations
- Modify codex_config to work with new database structure
- Ensure error handling covers database operations
This commit is contained in:
YoVinchen
2025-11-22 23:27:54 +08:00
parent 23a407544a
commit a2688603fb
3 changed files with 7 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ pub fn get_codex_config_path() -> PathBuf {
}
/// 获取 Codex 供应商配置文件路径
#[allow(dead_code)]
pub fn get_codex_provider_paths(
provider_id: &str,
provider_name: Option<&str>,
@@ -44,6 +45,7 @@ pub fn get_codex_provider_paths(
}
/// 删除 Codex 供应商配置文件
#[allow(dead_code)]
pub fn delete_codex_provider_config(
provider_id: &str,
provider_name: &str,

View File

@@ -50,6 +50,8 @@ pub enum AppError {
zh: String,
en: String,
},
#[error("数据库错误: {0}")]
Database(String),
}
impl AppError {

View File

@@ -1,3 +1,4 @@
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
@@ -64,7 +65,7 @@ impl Provider {
/// 供应商管理器
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ProviderManager {
pub providers: HashMap<String, Provider>,
pub providers: IndexMap<String, Provider>,
pub current: String,
}
@@ -154,7 +155,7 @@ pub struct ProviderMeta {
impl ProviderManager {
/// 获取所有供应商
pub fn get_all_providers(&self) -> &HashMap<String, Provider> {
pub fn get_all_providers(&self) -> &IndexMap<String, Provider> {
&self.providers
}
}