feat: load billing adapters #125

Merged
realaravinth merged 63 commits from load-billing-adapter into master 2025-01-11 19:41:14 +05:30
Showing only changes of commit 335714fa32 - Show all commits

View file

@ -0,0 +1,58 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
#![allow(dead_code)]
use std::sync::Arc;
use actix_web::web::Data;
use cqrs_es::{persist::ViewRepository, AggregateError};
use derive_builder::Builder;
use postgres_es::PostgresCqrs;
use crate::identity::{
adapters::{
// input::web::RoutesRepository,
output::db::postgres::{
employee_view::EmployeeView, store_view::StoreView, user_view::UserView,
DBOutPostgresAdapter,
},
},
application::services::{errors::IdentityError, IdentityCommand, IdentityServicesObj},
domain::{aggregate::User, employee_aggregate::Employee, store_aggregate::Store},
};
//
////pub type WebIdentityRoutesRepository = Data<Arc<RoutesRegit.batspository>>;
pub type IdentityUserCqrsExec = Arc<PostgresCqrs<User>>;
pub type IdentityUserCqrsView = Arc<dyn ViewRepository<UserView, User>>;
pub type WebIdentityUserCqrsView = Data<IdentityUserCqrsView>;
pub type IdentityStoreCqrsExec = Arc<PostgresCqrs<Store>>;
pub type IdentityStoreCqrsView = Arc<dyn ViewRepository<StoreView, Store>>;
pub type WebIdentityStoreCqrsView = Data<IdentityStoreCqrsView>;
pub type IdentityEmployeeCqrsExec = Arc<PostgresCqrs<Employee>>;
pub type IdentityEmployeeCqrsView = Arc<dyn ViewRepository<StoreView, Store>>;
pub type WebIdentityEmployeeCqrsView = Data<IdentityStoreCqrsView>;
pub type WebIdentityCqrsExec = Data<Arc<IdentityCqrsExec>>;
//
#[derive(Clone, Builder)]
pub struct IdentityCqrsExec {
user: IdentityUserCqrsExec,
store: IdentityStoreCqrsExec,
}
impl IdentityCqrsExec {
pub async fn execute(
&self,
aggregate_id: &str,
command: IdentityCommand,
) -> Result<(), AggregateError<IdentityError>> {
self.user.execute(aggregate_id, command.clone()).await?;
self.store.execute(aggregate_id, command).await?;
Ok(())
}
}