From 8871f46738ce4efea5eff93fb76eb4ed49a488c2 Mon Sep 17 00:00:00 2001 From: eraden Date: Sun, 17 Apr 2022 23:15:00 +0200 Subject: [PATCH] Add deliver days --- api/src/actors/database/products.rs | 41 +++++++++++++++++-------- api/src/routes/admin/api_v1/products.rs | 6 +++- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/api/src/actors/database/products.rs b/api/src/actors/database/products.rs index 9cf065d..29f852e 100644 --- a/api/src/actors/database/products.rs +++ b/api/src/actors/database/products.rs @@ -4,8 +4,8 @@ use sqlx::PgPool; use super::Result; use crate::database::Database; use crate::model::{ - PriceMajor, PriceMinor, Product, ProductCategory, ProductId, ProductLongDesc, ProductName, - ProductShortDesc, + Days, PriceMajor, PriceMinor, Product, ProductCategory, ProductId, ProductLongDesc, + ProductName, ProductShortDesc, }; use crate::{database, model}; @@ -58,6 +58,7 @@ pub struct CreateProduct { pub category: Option, pub price_major: PriceMajor, pub price_minor: PriceMinor, + pub deliver_days_flag: Days, } crate::db_async_handler!(CreateProduct, create_product, Product); @@ -66,14 +67,15 @@ pub(crate) async fn create_product(msg: CreateProduct, pool: PgPool) -> Result, pub price_major: PriceMajor, pub price_minor: PriceMinor, + pub deliver_days_flag: Days, } crate::db_async_handler!(UpdateProduct, update_product, Product); @@ -108,29 +112,32 @@ pub(crate) async fn update_product(msg: UpdateProduct, pool: PgPool) -> Result Result, pub price_major: PriceMajor, pub price_minor: PriceMinor, + pub deliver_days_flag: Days, } #[patch("/product")] @@ -50,6 +51,7 @@ async fn update_product( category: payload.category, price_major: payload.price_major, price_minor: payload.price_minor, + deliver_days_flag: payload.deliver_days_flag, } ); } @@ -62,6 +64,7 @@ pub struct CreateProduct { pub category: Option, pub price_major: PriceMajor, pub price_minor: PriceMinor, + pub deliver_days_flag: Days, } #[post("/product")] @@ -81,6 +84,7 @@ async fn create_product( category: payload.category, price_major: payload.price_major, price_minor: payload.price_minor, + deliver_days_flag: payload.deliver_days_flag, } ); }