diff --git a/src/service/product.rs b/src/service/product.rs index c928891bf872cf440bf4443a4d247dc885b847fc..10c6a96bb807d0c827d4b69bcdda4a56edd00a80 100644 --- a/src/service/product.rs +++ b/src/service/product.rs @@ -7,8 +7,7 @@ use bambangshop::{Result, compose_error_response}; use crate::model::notification::Notification; use crate::model::product::Product; use crate::repository::product::ProductRepository; - -use super::notification::NotificationService; +use crate::service::notification::NotificationService; pub struct ProductService; @@ -17,6 +16,8 @@ impl ProductService { product.product_type = product.product_type.to_uppercase(); let product_result: Product = ProductRepository::add(product); + NotificationService.notify(&product_result.product_type, "CREATED", + product_result.clone()); return Ok(product_result); } @@ -45,6 +46,7 @@ impl ProductService { } let product: Product = product_opt.unwrap(); + NotificationService.notify(&product.product_type, "DELETED", product.clone()); return Ok(Json::from(product)); }