diff options
Diffstat (limited to 'src/models.rs')
-rw-r--r-- | src/models.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/models.rs b/src/models.rs index acd67a6..a104209 100644 --- a/src/models.rs +++ b/src/models.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | use super::schema::{cart_items, customer, product, rating, transaction}; | 1 | use super::schema::{cart_items, customer, product, rating, transaction}; |
2 | 2 | ||
3 | use chrono::naive::{NaiveDate, NaiveDateTime}; | ||
3 | use diesel::{Insertable, Queryable}; | 4 | use diesel::{Insertable, Queryable}; |
4 | use serde::{Deserialize, Serialize}; | 5 | use serde::{Deserialize, Serialize}; |
5 | 6 | ||
@@ -70,3 +71,27 @@ pub struct AddCartItem { | |||
70 | pub cart_id: i32, | 71 | pub cart_id: i32, |
71 | pub product_id: i32, | 72 | pub product_id: i32, |
72 | } | 73 | } |
74 | |||
75 | /* Rating */ | ||
76 | #[derive(Queryable, Serialize)] | ||
77 | pub struct Rating { | ||
78 | pub id: i32, | ||
79 | pub comment_text: Option<String>, | ||
80 | pub comment_date: Option<NaiveDate>, | ||
81 | pub product_id: Option<i32>, | ||
82 | pub customer_id: Option<i32>, | ||
83 | pub stars: Option<i32>, | ||
84 | } | ||
85 | |||
86 | #[derive(Insertable, Deserialize)] | ||
87 | #[table_name = "rating"] | ||
88 | pub struct AddRating { | ||
89 | #[serde(skip_serializing_if = "Option::is_none")] | ||
90 | pub comment_text: Option<String>, | ||
91 | |||
92 | #[serde(skip_serializing_if = "Option::is_none")] | ||
93 | pub stars: Option<i32>, | ||
94 | |||
95 | pub product_id: i32, | ||
96 | pub customer_id: i32, | ||
97 | } | ||