From 335714fa3298e07fdb78f80d5a3ec867a6341946 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Thu, 9 Jan 2025 01:18:47 +0530 Subject: [PATCH] feat: define type aliases for identity domain --- src/identity/adapters/types.rs | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/identity/adapters/types.rs diff --git a/src/identity/adapters/types.rs b/src/identity/adapters/types.rs new file mode 100644 index 0000000..3895547 --- /dev/null +++ b/src/identity/adapters/types.rs @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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>; + +pub type IdentityUserCqrsExec = Arc>; +pub type IdentityUserCqrsView = Arc>; +pub type WebIdentityUserCqrsView = Data; + +pub type IdentityStoreCqrsExec = Arc>; +pub type IdentityStoreCqrsView = Arc>; +pub type WebIdentityStoreCqrsView = Data; + +pub type IdentityEmployeeCqrsExec = Arc>; +pub type IdentityEmployeeCqrsView = Arc>; +pub type WebIdentityEmployeeCqrsView = Data; + +pub type WebIdentityCqrsExec = Data>; +// +#[derive(Clone, Builder)] +pub struct IdentityCqrsExec { + user: IdentityUserCqrsExec, + store: IdentityStoreCqrsExec, +} + +impl IdentityCqrsExec { + pub async fn execute( + &self, + aggregate_id: &str, + command: IdentityCommand, + ) -> Result<(), AggregateError> { + self.user.execute(aggregate_id, command.clone()).await?; + self.store.execute(aggregate_id, command).await?; + + Ok(()) + } +}