feat: define type aliases for identity domain

This commit is contained in:
Aravinth Manivannan 2025-01-09 01:18:47 +05:30
parent 6dbeded24a
commit 335714fa32
Signed by: realaravinth
GPG key ID: F8F50389936984FF

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(())
}
}