feat: define type aliases for identity domain
This commit is contained in:
parent
6dbeded24a
commit
335714fa32
1 changed files with 58 additions and 0 deletions
58
src/identity/adapters/types.rs
Normal file
58
src/identity/adapters/types.rs
Normal 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(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue