diff options
author | Adam T. Carpenter <atc@53hor.net> | 2022-10-26 21:02:31 -0400 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2022-10-26 21:02:31 -0400 |
commit | 9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f (patch) | |
tree | db9ca419266117facecdff6d30460669f3148efb /dichroism/src/dtos | |
parent | f243a3b7341012227d6e8342a65f9c5d7784256f (diff) | |
download | theglassyladies-9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f.tar.xz theglassyladies-9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f.zip |
init: add some stories and personas and begin layout out domain
Diffstat (limited to 'dichroism/src/dtos')
-rw-r--r-- | dichroism/src/dtos/mod.rs | 9 | ||||
-rw-r--r-- | dichroism/src/dtos/photo_set_get.rs | 20 | ||||
-rw-r--r-- | dichroism/src/dtos/product_get.rs | 32 | ||||
-rw-r--r-- | dichroism/src/dtos/product_patch.rs | 31 | ||||
-rw-r--r-- | dichroism/src/dtos/product_post.rs | 11 |
5 files changed, 0 insertions, 103 deletions
diff --git a/dichroism/src/dtos/mod.rs b/dichroism/src/dtos/mod.rs deleted file mode 100644 index a3e27e5..0000000 --- a/dichroism/src/dtos/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod photo_set_get; -mod product_get; -mod product_patch; -mod product_post; - -pub use photo_set_get::*; -pub use product_get::*; -pub use product_patch::*; -pub use product_post::*; diff --git a/dichroism/src/dtos/photo_set_get.rs b/dichroism/src/dtos/photo_set_get.rs deleted file mode 100644 index b2e8d7b..0000000 --- a/dichroism/src/dtos/photo_set_get.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::models::PhotoSet; - -#[derive(Debug, Serialize)] -pub struct PhotoSetGet { - pub id: i32, - pub fullsize: String, - pub base: String, - pub thumbnail: String, -} - -impl From<PhotoSet> for PhotoSetGet { - fn from(p: PhotoSet) -> Self { - Self { - id: p.id.unwrap_or(-1), - fullsize: p.fullsize.id, - base: p.base.id, - thumbnail: p.thumbnail.id, - } - } -} diff --git a/dichroism/src/dtos/product_get.rs b/dichroism/src/dtos/product_get.rs deleted file mode 100644 index aa52f19..0000000 --- a/dichroism/src/dtos/product_get.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::models::Product; - -#[derive(Debug, Serialize)] -pub struct ProductGet { - pub id: i32, - pub name: String, - pub description: String, - pub cents: i32, - pub quantity: i32, - pub featured: bool, - pub photo_base: String, - pub photo_fullsize: String, - pub photo_thumbnail: String, - pub category: String, -} - -impl From<Product> for ProductGet { - fn from(p: Product) -> Self { - Self { - id: p.id.unwrap_or(-1), - name: p.name, - description: p.description, - cents: p.cents, - quantity: p.quantity, - featured: p.featured, - category: p.category, - photo_fullsize: p.photo_set.fullsize.id, - photo_base: p.photo_set.base.id, - photo_thumbnail: p.photo_set.thumbnail.id, - } - } -} diff --git a/dichroism/src/dtos/product_patch.rs b/dichroism/src/dtos/product_patch.rs deleted file mode 100644 index f231469..0000000 --- a/dichroism/src/dtos/product_patch.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::models::Product; - -#[derive(Debug, Deserialize)] -pub struct ProductPatch { - pub id: i32, - pub name: Option<String>, - pub quantity: Option<i32>, - pub cents: Option<i32>, - pub description: Option<String>, - pub featured: Option<bool>, - pub category_path: Option<String>, - pub photo_set: Option<i32>, -} - -impl ProductPatch { - pub fn patch(self, product: &mut Product) { - if let Some(name) = self.name { - product.name = name; - } - if let Some(category) = self.category_path { - product.category = category; - } - if let Some(description) = self.description { - product.description = description; - } - - product.quantity = self.quantity.unwrap_or(product.quantity); - product.cents = self.cents.unwrap_or(product.cents); - product.featured = self.featured.unwrap_or(product.featured); - } -} diff --git a/dichroism/src/dtos/product_post.rs b/dichroism/src/dtos/product_post.rs deleted file mode 100644 index c04b211..0000000 --- a/dichroism/src/dtos/product_post.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[derive(Debug, Deserialize)] -pub struct ProductPost { - pub id: Option<i32>, - pub name: String, - pub quantity: i32, - pub cents: i32, - pub description: String, - pub featured: bool, - pub category_path: String, - pub photo_set: i32, -} |