From 9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Wed, 26 Oct 2022 21:02:31 -0400 Subject: init: add some stories and personas and begin layout out domain --- dichroism/src/dtos/mod.rs | 9 --------- dichroism/src/dtos/photo_set_get.rs | 20 -------------------- dichroism/src/dtos/product_get.rs | 32 -------------------------------- dichroism/src/dtos/product_patch.rs | 31 ------------------------------- dichroism/src/dtos/product_post.rs | 11 ----------- 5 files changed, 103 deletions(-) delete mode 100644 dichroism/src/dtos/mod.rs delete mode 100644 dichroism/src/dtos/photo_set_get.rs delete mode 100644 dichroism/src/dtos/product_get.rs delete mode 100644 dichroism/src/dtos/product_patch.rs delete mode 100644 dichroism/src/dtos/product_post.rs (limited to 'dichroism/src/dtos') 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 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 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, - pub quantity: Option, - pub cents: Option, - pub description: Option, - pub featured: Option, - pub category_path: Option, - pub photo_set: Option, -} - -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, - pub name: String, - pub quantity: i32, - pub cents: i32, - pub description: String, - pub featured: bool, - pub category_path: String, - pub photo_set: i32, -} -- cgit v1.2.3