Add product v2
This commit is contained in:
parent
6c28472ace
commit
be005629ca
@ -1,10 +1,7 @@
|
||||
pub static CLIENT_NAME: &str = "stocks";
|
||||
|
||||
pub mod create_product {
|
||||
use model::{
|
||||
Days, Price, ProductCategory, ProductLongDesc, ProductName, ProductShortDesc, Quantity,
|
||||
QuantityUnit,
|
||||
};
|
||||
use model::v2::*;
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ProductInput {
|
||||
|
@ -898,19 +898,95 @@ impl ProductCategory {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct DetailedProduct {
|
||||
pub id: ProductId,
|
||||
pub name: ProductName,
|
||||
pub short_description: ProductShortDesc,
|
||||
pub long_description: ProductLongDesc,
|
||||
pub category: Option<ProductCategory>,
|
||||
pub price: Price,
|
||||
pub deliver_days_flag: Days,
|
||||
pub mod v2 {
|
||||
pub use crate::{
|
||||
Days, FileName, LocalPath, PhotoId, Price, ProductCategory, ProductId, ProductLongDesc,
|
||||
ProductName, ProductPhotoId, ProductShortDesc, Quantity, QuantityUnit, RecordId, StockId,
|
||||
UniqueName,
|
||||
};
|
||||
|
||||
pub stocks: Vec<Stock>,
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
#[cfg_attr(feature = "db", derive(sqlx::Type))]
|
||||
#[cfg_attr(feature = "db", sqlx(transparent))]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Deref, From)]
|
||||
#[serde(transparent)]
|
||||
pub struct ProductVariantId(RecordId);
|
||||
|
||||
pub photos: Vec<Photo>,
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct DetailedProduct {
|
||||
pub id: ProductId,
|
||||
pub name: ProductName,
|
||||
pub short_description: ProductShortDesc,
|
||||
pub long_description: ProductLongDesc,
|
||||
pub category: Option<ProductCategory>,
|
||||
pub price: Price,
|
||||
pub deliver_days_flag: Days,
|
||||
|
||||
pub stocks: Vec<Stock>,
|
||||
|
||||
pub photos: Vec<Photo>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Product {
|
||||
pub id: ProductId,
|
||||
pub name: ProductName,
|
||||
pub category: Option<ProductCategory>,
|
||||
pub deliver_days_flag: Days,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ProductVariant {
|
||||
pub id: ProductVariantId,
|
||||
pub name: ProductName,
|
||||
pub short_description: ProductShortDesc,
|
||||
pub long_description: ProductLongDesc,
|
||||
pub price: Price,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Stock {
|
||||
pub id: StockId,
|
||||
pub product_variant_id: ProductVariantId,
|
||||
pub quantity: Quantity,
|
||||
pub quantity_unit: QuantityUnit,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Photo {
|
||||
pub id: PhotoId,
|
||||
pub local_path: LocalPath,
|
||||
pub file_name: FileName,
|
||||
pub unique_name: UniqueName,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ProductLinkedPhoto {
|
||||
pub photo_id: PhotoId,
|
||||
pub local_path: LocalPath,
|
||||
pub file_name: FileName,
|
||||
pub unique_name: UniqueName,
|
||||
pub product_variant_id: ProductVariantId,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ProductPhoto {
|
||||
pub id: ProductPhotoId,
|
||||
pub product_variant_id: ProductVariantId,
|
||||
pub photo_id: PhotoId,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
|
||||
|
@ -0,0 +1 @@
|
||||
use model::v2::*;
|
@ -0,0 +1 @@
|
||||
use model::v2::*;
|
@ -0,0 +1 @@
|
||||
use model::v2::*;
|
@ -0,0 +1 @@
|
||||
use model::v2::*;
|
Loading…
Reference in New Issue
Block a user