Procházet zdrojové kódy

✨ refactor(commands): 重构命令模块,将 get_category 和 get_table 函数移至独立文件

陈雪 před 1 dnem
rodič
revize
abfd34408a

+ 15 - 0
src-tauri/src/commands/category.rs

@@ -0,0 +1,15 @@
+use crate::{
+    CmdResult, CmdState,
+    service::category::{Category, CategoryWithSpu},
+};
+
+#[tauri::command]
+pub async fn get_category(app_state: CmdState<'_>) -> CmdResult<Vec<CategoryWithSpu>> {
+    let category = Category::new(app_state.conn.clone());
+    let categories = category.get_category_commodity().await;
+    match categories {
+        Ok(categories) => Ok(categories),
+        Err(e) => Err(format!("请求分类失败{:?}", e)),
+    }
+    // Ok("111".into())
+}

+ 2 - 15
src-tauri/src/commands/mod.rs

@@ -1,15 +1,2 @@
-use crate::{
-    CmdResult, CmdState,
-    service::category::{Category, CategoryWithSpu},
-};
-
-#[tauri::command]
-pub async fn get_category(app_state: CmdState<'_>) -> CmdResult<Vec<CategoryWithSpu>> {
-    let category = Category::new(app_state.conn.clone());
-    let categories = category.get_category_commodity().await;
-    match categories {
-        Ok(categories) => Ok(categories),
-        Err(e) => Err(format!("请求分类失败{:?}", e)),
-    }
-    // Ok("111".into())
-}
+pub mod category;
+pub mod table;

+ 15 - 0
src-tauri/src/commands/table.rs

@@ -0,0 +1,15 @@
+use crate::{
+    CmdResult, CmdState,
+    service::category::{Category, CategoryWithSpu},
+};
+
+#[tauri::command]
+pub async fn get_table(app_state: CmdState<'_>) -> CmdResult<Vec<CategoryWithSpu>> {
+    let category = Category::new(app_state.conn.clone());
+    let categories = category.get_category_commodity().await;
+    match categories {
+        Ok(categories) => Ok(categories),
+        Err(e) => Err(format!("请求分类失败{:?}", e)),
+    }
+    // Ok("111".into())
+}