feat: load billing adapters #125
5 changed files with 74 additions and 5 deletions
|
@ -10,6 +10,8 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use super::errors::*;
|
use super::errors::*;
|
||||||
use super::InventoryDBPostgresAdapter;
|
use super::InventoryDBPostgresAdapter;
|
||||||
|
use crate::inventory::adapters::types::{InventoryCategoryCqrsExec, InventoryCategoryCqrsView};
|
||||||
|
use crate::inventory::application::services::InventoryServicesObj;
|
||||||
use crate::inventory::domain::category_aggregate::{Category, CategoryBuilder};
|
use crate::inventory::domain::category_aggregate::{Category, CategoryBuilder};
|
||||||
use crate::inventory::domain::events::InventoryEvent;
|
use crate::inventory::domain::events::InventoryEvent;
|
||||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||||
|
@ -229,6 +231,20 @@ impl Query<Category> for InventoryDBPostgresAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_cqrs(
|
||||||
|
db: InventoryDBPostgresAdapter,
|
||||||
|
services: InventoryServicesObj,
|
||||||
|
) -> (InventoryCategoryCqrsExec, InventoryCategoryCqrsView) {
|
||||||
|
let queries: Vec<Box<dyn Query<Category>>> = vec![Box::new(db.clone())];
|
||||||
|
|
||||||
|
let pool = db.pool.clone();
|
||||||
|
|
||||||
|
(
|
||||||
|
std::sync::Arc::new(postgres_es::postgres_cqrs(pool.clone(), queries, services)),
|
||||||
|
std::sync::Arc::new(db.clone()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -12,6 +12,10 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use super::errors::*;
|
use super::errors::*;
|
||||||
use super::InventoryDBPostgresAdapter;
|
use super::InventoryDBPostgresAdapter;
|
||||||
|
use crate::inventory::adapters::types::{
|
||||||
|
InventoryCustomizationCqrsExec, InventoryCustomizationCqrsView,
|
||||||
|
};
|
||||||
|
use crate::inventory::application::services::InventoryServicesObj;
|
||||||
use crate::inventory::domain::{customization_aggregate::*, events::InventoryEvent};
|
use crate::inventory::domain::{customization_aggregate::*, events::InventoryEvent};
|
||||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||||
|
|
||||||
|
@ -23,7 +27,7 @@ pub const NEW_CUSTOMIZATION_NON_UUID: &str = "new_customization_non_uuid-asdfa";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||||
struct CustomizationView {
|
pub struct CustomizationView {
|
||||||
name: String,
|
name: String,
|
||||||
product_id: Uuid,
|
product_id: Uuid,
|
||||||
customization_id: Uuid,
|
customization_id: Uuid,
|
||||||
|
@ -224,6 +228,23 @@ impl Query<Customization> for InventoryDBPostgresAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_cqrs(
|
||||||
|
db: InventoryDBPostgresAdapter,
|
||||||
|
services: InventoryServicesObj,
|
||||||
|
) -> (
|
||||||
|
InventoryCustomizationCqrsExec,
|
||||||
|
InventoryCustomizationCqrsView,
|
||||||
|
) {
|
||||||
|
let queries: Vec<Box<dyn Query<Customization>>> = vec![Box::new(db.clone())];
|
||||||
|
|
||||||
|
let pool = db.pool.clone();
|
||||||
|
|
||||||
|
(
|
||||||
|
std::sync::Arc::new(postgres_es::postgres_cqrs(pool.clone(), queries, services)),
|
||||||
|
std::sync::Arc::new(db.clone()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -10,18 +10,18 @@ use crate::db::{migrate::RunMigrations, sqlx_postgres::Postgres};
|
||||||
|
|
||||||
mod category_id_exists;
|
mod category_id_exists;
|
||||||
mod category_name_exists_for_store;
|
mod category_name_exists_for_store;
|
||||||
mod category_view;
|
pub mod category_view;
|
||||||
mod customization_id_exists;
|
mod customization_id_exists;
|
||||||
mod customization_name_exists_for_product;
|
mod customization_name_exists_for_product;
|
||||||
mod customization_view;
|
pub mod customization_view;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod get_category;
|
mod get_category;
|
||||||
mod product_id_exists;
|
mod product_id_exists;
|
||||||
mod product_name_exists_for_category;
|
mod product_name_exists_for_category;
|
||||||
mod product_view;
|
pub mod product_view;
|
||||||
mod store_id_exists;
|
mod store_id_exists;
|
||||||
mod store_name_exists;
|
mod store_name_exists;
|
||||||
mod store_view;
|
pub mod store_view;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct InventoryDBPostgresAdapter {
|
pub struct InventoryDBPostgresAdapter {
|
||||||
|
|
|
@ -12,6 +12,8 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use super::errors::*;
|
use super::errors::*;
|
||||||
use super::InventoryDBPostgresAdapter;
|
use super::InventoryDBPostgresAdapter;
|
||||||
|
use crate::inventory::adapters::types::{InventoryProductCqrsExec, InventoryProductCqrsView};
|
||||||
|
use crate::inventory::application::services::InventoryServicesObj;
|
||||||
use crate::inventory::domain::events::InventoryEvent;
|
use crate::inventory::domain::events::InventoryEvent;
|
||||||
use crate::inventory::domain::product_aggregate::{Product, ProductBuilder};
|
use crate::inventory::domain::product_aggregate::{Product, ProductBuilder};
|
||||||
use crate::types::currency::*;
|
use crate::types::currency::*;
|
||||||
|
@ -348,6 +350,20 @@ impl Query<Product> for InventoryDBPostgresAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_cqrs(
|
||||||
|
db: InventoryDBPostgresAdapter,
|
||||||
|
services: InventoryServicesObj,
|
||||||
|
) -> (InventoryProductCqrsExec, InventoryProductCqrsView) {
|
||||||
|
let queries: Vec<Box<dyn Query<Product>>> = vec![Box::new(db.clone())];
|
||||||
|
|
||||||
|
let pool = db.pool.clone();
|
||||||
|
|
||||||
|
(
|
||||||
|
std::sync::Arc::new(postgres_es::postgres_cqrs(pool.clone(), queries, services)),
|
||||||
|
std::sync::Arc::new(db.clone()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -10,6 +10,8 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use super::errors::*;
|
use super::errors::*;
|
||||||
use super::InventoryDBPostgresAdapter;
|
use super::InventoryDBPostgresAdapter;
|
||||||
|
use crate::inventory::adapters::types::{InventoryStoreCqrsExec, InventoryStoreCqrsView};
|
||||||
|
use crate::inventory::application::services::InventoryServicesObj;
|
||||||
use crate::inventory::domain::events::InventoryEvent;
|
use crate::inventory::domain::events::InventoryEvent;
|
||||||
use crate::inventory::domain::store_aggregate::{Store, StoreBuilder};
|
use crate::inventory::domain::store_aggregate::{Store, StoreBuilder};
|
||||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||||
|
@ -225,6 +227,20 @@ impl Query<Store> for InventoryDBPostgresAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_cqrs(
|
||||||
|
db: InventoryDBPostgresAdapter,
|
||||||
|
services: InventoryServicesObj,
|
||||||
|
) -> (InventoryStoreCqrsExec, InventoryStoreCqrsView) {
|
||||||
|
let queries: Vec<Box<dyn Query<Store>>> = vec![Box::new(db.clone())];
|
||||||
|
|
||||||
|
let pool = db.pool.clone();
|
||||||
|
|
||||||
|
(
|
||||||
|
std::sync::Arc::new(postgres_es::postgres_cqrs(pool.clone(), queries, services)),
|
||||||
|
std::sync::Arc::new(db.clone()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in a new issue