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:
@@ -29,6 +29,7 @@ pub fn get_codex_config_path() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 获取 Codex 供应商配置文件路径
|
/// 获取 Codex 供应商配置文件路径
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_codex_provider_paths(
|
pub fn get_codex_provider_paths(
|
||||||
provider_id: &str,
|
provider_id: &str,
|
||||||
provider_name: Option<&str>,
|
provider_name: Option<&str>,
|
||||||
@@ -44,6 +45,7 @@ pub fn get_codex_provider_paths(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 删除 Codex 供应商配置文件
|
/// 删除 Codex 供应商配置文件
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn delete_codex_provider_config(
|
pub fn delete_codex_provider_config(
|
||||||
provider_id: &str,
|
provider_id: &str,
|
||||||
provider_name: &str,
|
provider_name: &str,
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ pub enum AppError {
|
|||||||
zh: String,
|
zh: String,
|
||||||
en: String,
|
en: String,
|
||||||
},
|
},
|
||||||
|
#[error("数据库错误: {0}")]
|
||||||
|
Database(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppError {
|
impl AppError {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use indexmap::IndexMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@@ -64,7 +65,7 @@ impl Provider {
|
|||||||
/// 供应商管理器
|
/// 供应商管理器
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct ProviderManager {
|
pub struct ProviderManager {
|
||||||
pub providers: HashMap<String, Provider>,
|
pub providers: IndexMap<String, Provider>,
|
||||||
pub current: String,
|
pub current: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +155,7 @@ pub struct ProviderMeta {
|
|||||||
|
|
||||||
impl ProviderManager {
|
impl ProviderManager {
|
||||||
/// 获取所有供应商
|
/// 获取所有供应商
|
||||||
pub fn get_all_providers(&self) -> &HashMap<String, Provider> {
|
pub fn get_all_providers(&self) -> &IndexMap<String, Provider> {
|
||||||
&self.providers
|
&self.providers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user