mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-03 22:26:43 +00:00
refactor: remove unused extension and command CRUD operations from db module
This commit is contained in:
parent
8fd3223b66
commit
3596f0b8a4
@ -81,23 +81,23 @@ const COMMANDS: &[&str] = &[
|
||||
// "ext_store_wrapper_save",
|
||||
"get_server_port",
|
||||
/* ----------------------------- sqlite database ---------------------------- */
|
||||
"create_extension",
|
||||
"get_all_extensions",
|
||||
"get_unique_extension_by_identifier",
|
||||
"get_unique_extension_by_path",
|
||||
"get_all_extensions_by_identifier",
|
||||
"delete_extension_by_path",
|
||||
"delete_extension_by_ext_id",
|
||||
"create_command",
|
||||
"get_command_by_id",
|
||||
"get_commands_by_ext_id",
|
||||
"delete_command_by_id",
|
||||
"update_command_by_id",
|
||||
"create_extension_data",
|
||||
"get_extension_data_by_id",
|
||||
"search_extension_data",
|
||||
"delete_extension_data_by_id",
|
||||
"update_extension_data_by_id",
|
||||
// "create_extension",
|
||||
// "get_all_extensions",
|
||||
// "get_unique_extension_by_identifier",
|
||||
// "get_unique_extension_by_path",
|
||||
// "get_all_extensions_by_identifier",
|
||||
// "delete_extension_by_path",
|
||||
// "delete_extension_by_ext_id",
|
||||
// "create_command",
|
||||
// "get_command_by_id",
|
||||
// "get_commands_by_ext_id",
|
||||
// "delete_command_by_id",
|
||||
// "update_command_by_id",
|
||||
// "create_extension_data",
|
||||
// "get_extension_data_by_id",
|
||||
// "search_extension_data",
|
||||
// "delete_extension_data_by_id",
|
||||
// "update_extension_data_by_id",
|
||||
"select",
|
||||
"execute",
|
||||
/* -------------------------------- Clipboard ------------------------------- */
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
## Permission Table
|
||||
|
||||
<table>
|
||||
@ -6,6 +7,7 @@
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
@ -22,231 +22,6 @@ impl DBState {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Extension CRUD */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#[tauri::command]
|
||||
pub async fn create_extension(
|
||||
db: State<'_, DBState>,
|
||||
identifier: &str,
|
||||
version: &str,
|
||||
enabled: Option<bool>,
|
||||
path: Option<&str>,
|
||||
data: Option<&str>,
|
||||
) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.create_extension(identifier, version, enabled.unwrap_or(true), path, data)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_all_extensions(db: State<'_, DBState>) -> Result<Vec<Ext>, String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_all_extensions()
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_all_extensions_by_identifier(
|
||||
identifier: &str,
|
||||
db: State<'_, DBState>,
|
||||
) -> Result<Vec<Ext>, String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_all_extensions_by_identifier(identifier)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_unique_extension_by_identifier(
|
||||
identifier: &str,
|
||||
db: State<'_, DBState>,
|
||||
) -> Result<Option<Ext>, String> {
|
||||
let ext = db
|
||||
.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_unique_extension_by_identifier(identifier)
|
||||
.map_err(|err| err.to_string())?;
|
||||
Ok(ext)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_unique_extension_by_path(
|
||||
path: &str,
|
||||
db: State<'_, DBState>,
|
||||
) -> Result<Option<Ext>, String> {
|
||||
let ext = db
|
||||
.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_unique_extension_by_path(path)
|
||||
.map_err(|err| err.to_string())?;
|
||||
Ok(ext)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_extension_by_path(path: &str, db: State<'_, DBState>) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.delete_extension_by_path(path)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_extension_by_ext_id(ext_id: i32, db: State<'_, DBState>) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.delete_extension_by_ext_id(ext_id)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Extension Command CRUD */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn create_command(
|
||||
db: State<'_, DBState>,
|
||||
ext_id: i32,
|
||||
name: &str,
|
||||
cmd_type: CmdType,
|
||||
data: &str,
|
||||
enabled: bool,
|
||||
alias: Option<&str>,
|
||||
hotkey: Option<&str>,
|
||||
) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.create_command(ext_id, name, cmd_type, data, enabled, alias, hotkey)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_command_by_id(db: State<'_, DBState>, cmd_id: i32) -> Result<Option<Cmd>, String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_command_by_id(cmd_id)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_commands_by_ext_id(
|
||||
db: State<'_, DBState>,
|
||||
ext_id: i32,
|
||||
) -> Result<Vec<Cmd>, String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_commands_by_ext_id(ext_id)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_command_by_id(db: State<'_, DBState>, cmd_id: i32) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.delete_command_by_id(cmd_id)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn update_command_by_id(
|
||||
db: State<'_, DBState>,
|
||||
cmd_id: i32,
|
||||
name: &str,
|
||||
cmd_type: CmdType,
|
||||
data: &str,
|
||||
enabled: bool,
|
||||
alias: Option<&str>,
|
||||
hotkey: Option<&str>,
|
||||
) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.update_command_by_id(cmd_id, name, cmd_type, data, enabled, alias, hotkey)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Extension Data CRUD */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#[tauri::command]
|
||||
pub async fn create_extension_data(
|
||||
ext_id: i32,
|
||||
data_type: &str,
|
||||
data: &str,
|
||||
search_text: Option<&str>,
|
||||
db: State<'_, DBState>,
|
||||
) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.create_extension_data(ext_id, data_type, data, search_text, None)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_extension_data_by_id(
|
||||
data_id: i32,
|
||||
fields: Option<Vec<ExtDataField>>,
|
||||
db: State<'_, DBState>,
|
||||
) -> Result<Option<ExtData>, String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_extension_data_by_id(data_id, fields)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn search_extension_data(
|
||||
db: State<'_, DBState>,
|
||||
search_query: ExtDataSearchQuery,
|
||||
) -> Result<Vec<ExtData>, String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.search_extension_data(search_query)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_extension_data_by_id(
|
||||
data_id: i32,
|
||||
db: State<'_, DBState>,
|
||||
) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.delete_extension_data_by_id(data_id)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn update_extension_data_by_id(
|
||||
data_id: i32,
|
||||
data: &str,
|
||||
search_text: Option<&str>,
|
||||
db: State<'_, DBState>,
|
||||
) -> Result<(), String> {
|
||||
db.db
|
||||
.lock()
|
||||
.unwrap()
|
||||
.update_extension_data_by_id(data_id, data, search_text)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn select(
|
||||
db: State<'_, DBState>,
|
||||
|
@ -142,24 +142,6 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
/* -------------------------------- database -------------------------------- */
|
||||
commands::db::select,
|
||||
commands::db::execute,
|
||||
commands::db::create_extension,
|
||||
commands::db::create_extension,
|
||||
commands::db::get_all_extensions,
|
||||
commands::db::get_unique_extension_by_identifier,
|
||||
commands::db::get_unique_extension_by_path,
|
||||
commands::db::get_all_extensions_by_identifier,
|
||||
commands::db::delete_extension_by_path,
|
||||
commands::db::delete_extension_by_ext_id,
|
||||
commands::db::create_command,
|
||||
commands::db::get_command_by_id,
|
||||
commands::db::get_commands_by_ext_id,
|
||||
commands::db::delete_command_by_id,
|
||||
commands::db::update_command_by_id,
|
||||
commands::db::create_extension_data,
|
||||
commands::db::get_extension_data_by_id,
|
||||
commands::db::search_extension_data,
|
||||
commands::db::delete_extension_data_by_id,
|
||||
commands::db::update_extension_data_by_id,
|
||||
/* -------------------------------- Clipboard ------------------------------- */
|
||||
commands::clipboard::get_history,
|
||||
commands::clipboard::add_to_history,
|
||||
|
Loading…
x
Reference in New Issue
Block a user