use tauri::State;

use crate::{
    AppState, CmdResult,
    service::category::{Category, CategoryWithSpu},
};

#[tauri::command]
pub async fn get_category(app_state: State<'_, AppState>) -> 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())
}
