From 2a112855e54ea3a365fa032e8726196a7eec9a06 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 16 Dec 2020 22:12:50 +0530 Subject: begin working on rating endpoints --- src/models.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/models.rs') 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 @@ use super::schema::{cart_items, customer, product, rating, transaction}; +use chrono::naive::{NaiveDate, NaiveDateTime}; use diesel::{Insertable, Queryable}; use serde::{Deserialize, Serialize}; @@ -70,3 +71,27 @@ pub struct AddCartItem { pub cart_id: i32, pub product_id: i32, } + +/* Rating */ +#[derive(Queryable, Serialize)] +pub struct Rating { + pub id: i32, + pub comment_text: Option, + pub comment_date: Option, + pub product_id: Option, + pub customer_id: Option, + pub stars: Option, +} + +#[derive(Insertable, Deserialize)] +#[table_name = "rating"] +pub struct AddRating { + #[serde(skip_serializing_if = "Option::is_none")] + pub comment_text: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub stars: Option, + + pub product_id: i32, + pub customer_id: i32, +} -- cgit v1.2.3