mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 19:45:34 +08:00
feat(pi): add native catalog and gateway data plane
This commit is contained in:
@@ -6,6 +6,24 @@ use indexmap::IndexMap;
|
||||
use rusqlite::{params, OptionalExtension, Row};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
pub(super) fn delete_provider_on_tx(
|
||||
tx: &rusqlite::Transaction<'_>,
|
||||
app_type: &str,
|
||||
id: &str,
|
||||
) -> Result<(), AppError> {
|
||||
if tx
|
||||
.execute(
|
||||
"DELETE FROM providers WHERE id = ?1 AND app_type = ?2",
|
||||
params![id, app_type],
|
||||
)
|
||||
.map_err(|error| AppError::Database(error.to_string()))?
|
||||
!= 1
|
||||
{
|
||||
return Err(AppError::NotFound(format!("provider '{app_type}/{id}'")));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) struct StoredProviderRow {
|
||||
id: String,
|
||||
name: String,
|
||||
@@ -330,6 +348,16 @@ impl Database {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn clear_current_provider_for_app(&self, app_type: &str) -> Result<(), AppError> {
|
||||
let conn = lock_conn!(self.conn);
|
||||
conn.execute(
|
||||
"UPDATE providers SET is_current = 0 WHERE app_type = ?1",
|
||||
params![app_type],
|
||||
)
|
||||
.map_err(|error| AppError::Database(error.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_omo_provider_current(
|
||||
&self,
|
||||
app_type: &str,
|
||||
|
||||
Reference in New Issue
Block a user