This commit is contained in:
root 2025-07-11 00:34:04 +08:00
parent 010080f61e
commit a56336b63e
1 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use tauri::{command, AppHandle};
use crate::python_executor::execute_python_command;
use crate::python_executor::{execute_python_command, PythonExecutorConfig};
#[derive(Debug, Serialize, Deserialize)]
pub struct CreateCategoryRequest {
@ -20,10 +20,11 @@ pub struct UpdateCategoryRequest {
#[command]
pub async fn get_all_resource_categories(app: AppHandle) -> Result<String, String> {
let args = vec![
"-m".to_string(),
"python_core.services.resource_category_manager".to_string(),
"get_all_categories".to_string(),
];
execute_python_command(app, &args, None).await
}
@ -31,11 +32,12 @@ pub async fn get_all_resource_categories(app: AppHandle) -> Result<String, Strin
#[command]
pub async fn get_resource_category_by_id(app: AppHandle, category_id: String) -> Result<String, String> {
let args = vec![
"-m".to_string(),
"python_core.services.resource_category_manager".to_string(),
"get_category_by_id".to_string(),
category_id,
];
execute_python_command(app, &args, None).await
}
@ -43,13 +45,14 @@ pub async fn get_resource_category_by_id(app: AppHandle, category_id: String) ->
#[command]
pub async fn create_resource_category(app: AppHandle, request: CreateCategoryRequest) -> Result<String, String> {
let args = vec![
"-m".to_string(),
"python_core.services.resource_category_manager".to_string(),
"create_category".to_string(),
request.title,
request.ai_prompt,
request.color,
];
execute_python_command(app, &args, None).await
}
@ -62,14 +65,15 @@ pub async fn update_resource_category(
) -> Result<String, String> {
let request_json = serde_json::to_string(&request)
.map_err(|e| format!("Failed to serialize request: {}", e))?;
let args = vec![
"-m".to_string(),
"python_core.services.resource_category_manager".to_string(),
"update_category".to_string(),
category_id,
request_json,
];
execute_python_command(app, &args, None).await
}
@ -77,11 +81,12 @@ pub async fn update_resource_category(
#[command]
pub async fn delete_resource_category(app: AppHandle, category_id: String) -> Result<String, String> {
let args = vec![
"-m".to_string(),
"python_core.services.resource_category_manager".to_string(),
"delete_category".to_string(),
category_id,
];
execute_python_command(app, &args, None).await
}