Categories rpc

This commit is contained in:
eraden 2022-11-29 08:46:02 +01:00
parent 376c1084ab
commit 864f9842f0
5 changed files with 122 additions and 3 deletions

29
Cargo.lock generated
View File

@ -571,6 +571,7 @@ dependencies = [
"model", "model",
"rumqttc", "rumqttc",
"serde", "serde",
"strum",
"tarpc", "tarpc",
"thiserror", "thiserror",
"tokio", "tokio",
@ -3078,6 +3079,12 @@ dependencies = [
"base64", "base64",
] ]
[[package]]
name = "rustversion"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
[[package]] [[package]]
name = "rusty-money" name = "rusty-money"
version = "0.4.1" version = "0.4.1"
@ -3595,6 +3602,28 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 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]] [[package]]
name = "subtle" name = "subtle"
version = "2.4.1" version = "2.4.1"

View File

@ -24,3 +24,4 @@ thiserror = { version = "1.0.37" }
tokio = { version = "1.21.2", features = ['full'] } tokio = { version = "1.21.2", features = ['full'] }
tracing = { version = "0.1.37" } tracing = { version = "0.1.37" }
whatlang = { version = "0.16.2" } whatlang = { version = "0.16.2" }
strum = { version = "0.24.1", features = ['strum_macros', 'default'] }

View 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,
}

View File

@ -1,12 +1,13 @@
pub mod categories;
pub mod load; pub mod load;
pub mod product; pub mod product;
pub mod product_photo; pub mod product_photo;
pub mod product_stock; pub mod product_stock;
pub mod product_variant; pub mod product_variant;
pub use categories::*;
pub use load::*; pub use load::*;
use model::v2::ProductVariantId; use model::v2::{ProductId, ProductVariantId};
use model::ProductId;
pub use product::*; pub use product::*;
pub use product_photo::*; pub use product_photo::*;
pub use product_stock::*; pub use product_stock::*;
@ -127,6 +128,8 @@ pub mod rpc {
async fn shopping_cart_product_variants( async fn shopping_cart_product_variants(
input: find_product_variants::Input, input: find_product_variants::Input,
) -> find_product_variants::Output; ) -> find_product_variants::Output;
// async fn
} }
pub async fn create_client(config: SharedAppConfig) -> StocksClient { pub async fn create_client(config: SharedAppConfig) -> StocksClient {

View File

@ -243,7 +243,7 @@ mod utils {
.map( .map(
|ProductLinkedPhoto { |ProductLinkedPhoto {
photo_id, photo_id,
local_path, local_path: _,
file_name, file_name,
unique_name, unique_name,
product_variant_id: _, product_variant_id: _,