bazzar/crates/channels/src/stocks/categories.rs

87 lines
1.9 KiB
Rust
Raw Normal View History

2022-11-29 08:46:02 +01:00
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,
}