Categories rpc
This commit is contained in:
parent
376c1084ab
commit
864f9842f0
29
Cargo.lock
generated
29
Cargo.lock
generated
@ -571,6 +571,7 @@ dependencies = [
|
||||
"model",
|
||||
"rumqttc",
|
||||
"serde",
|
||||
"strum",
|
||||
"tarpc",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
@ -3078,6 +3079,12 @@ dependencies = [
|
||||
"base64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
|
||||
|
||||
[[package]]
|
||||
name = "rusty-money"
|
||||
version = "0.4.1"
|
||||
@ -3595,6 +3602,28 @@ version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
|
||||
dependencies = [
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.24.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.4.1"
|
||||
|
@ -24,3 +24,4 @@ thiserror = { version = "1.0.37" }
|
||||
tokio = { version = "1.21.2", features = ['full'] }
|
||||
tracing = { version = "0.1.37" }
|
||||
whatlang = { version = "0.16.2" }
|
||||
strum = { version = "0.24.1", features = ['strum_macros', 'default'] }
|
||||
|
86
crates/channels/src/stocks/categories.rs
Normal file
86
crates/channels/src/stocks/categories.rs
Normal file
@ -0,0 +1,86 @@
|
||||
use strum::IntoStaticStr;
|
||||
|
||||
pub mod create_category {
|
||||
use model::v2::*;
|
||||
|
||||
use crate::stocks::Error;
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Input {
|
||||
pub parent_id: Option<CategoryId>,
|
||||
pub name: CategoryName,
|
||||
pub key: CategoryKey,
|
||||
pub svg: CategorySvg,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Details {
|
||||
pub product: Category,
|
||||
}
|
||||
|
||||
pub type Output = Result<Details, Error>;
|
||||
}
|
||||
|
||||
pub mod delete_category {
|
||||
use model::v2::*;
|
||||
|
||||
use crate::stocks::Error;
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Input {
|
||||
pub category_id: CategoryId,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Details {}
|
||||
|
||||
pub type Output = Result<Details, Error>;
|
||||
}
|
||||
|
||||
pub mod update_category {
|
||||
use model::v2::*;
|
||||
|
||||
use crate::stocks::Error;
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Input {
|
||||
pub id: CategoryId,
|
||||
pub parent_id: Option<CategoryId>,
|
||||
pub name: CategoryName,
|
||||
pub key: CategoryKey,
|
||||
pub svg: CategorySvg,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Details {
|
||||
pub limit: Limit,
|
||||
pub offset: Offset,
|
||||
}
|
||||
|
||||
pub type Output = Result<Details, Error>;
|
||||
}
|
||||
|
||||
pub mod all_categories {
|
||||
use model::v2::*;
|
||||
|
||||
use crate::stocks::Error;
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Input {}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Details {
|
||||
pub categories: Vec<Category>,
|
||||
}
|
||||
|
||||
pub type Output = Result<Details, Error>;
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Copy, Clone, Debug, PartialOrd, PartialEq, serde::Serialize, serde::Deserialize, IntoStaticStr,
|
||||
)]
|
||||
pub enum Topic {
|
||||
CategoryCreated,
|
||||
CategoryUpdated,
|
||||
CategoryDeleted,
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
pub mod categories;
|
||||
pub mod load;
|
||||
pub mod product;
|
||||
pub mod product_photo;
|
||||
pub mod product_stock;
|
||||
pub mod product_variant;
|
||||
|
||||
pub use categories::*;
|
||||
pub use load::*;
|
||||
use model::v2::ProductVariantId;
|
||||
use model::ProductId;
|
||||
use model::v2::{ProductId, ProductVariantId};
|
||||
pub use product::*;
|
||||
pub use product_photo::*;
|
||||
pub use product_stock::*;
|
||||
@ -127,6 +128,8 @@ pub mod rpc {
|
||||
async fn shopping_cart_product_variants(
|
||||
input: find_product_variants::Input,
|
||||
) -> find_product_variants::Output;
|
||||
|
||||
// async fn
|
||||
}
|
||||
|
||||
pub async fn create_client(config: SharedAppConfig) -> StocksClient {
|
||||
|
@ -243,7 +243,7 @@ mod utils {
|
||||
.map(
|
||||
|ProductLinkedPhoto {
|
||||
photo_id,
|
||||
local_path,
|
||||
local_path: _,
|
||||
file_name,
|
||||
unique_name,
|
||||
product_variant_id: _,
|
||||
|
Loading…
Reference in New Issue
Block a user