feat: wrapup worker handler + auto-generate job
This commit is contained in:
40
crates/application/src/wrapup/event_handler.rs
Normal file
40
crates/application/src/wrapup/event_handler.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use async_trait::async_trait;
|
||||
use domain::errors::DomainError;
|
||||
use domain::events::DomainEvent;
|
||||
use domain::ports::EventHandler;
|
||||
|
||||
use crate::context::AppContext;
|
||||
|
||||
pub struct WrapUpEventHandler {
|
||||
ctx: AppContext,
|
||||
}
|
||||
|
||||
impl WrapUpEventHandler {
|
||||
pub fn new(ctx: AppContext) -> Self {
|
||||
Self { ctx }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl EventHandler for WrapUpEventHandler {
|
||||
async fn handle(&self, event: &DomainEvent) -> Result<(), DomainError> {
|
||||
match event {
|
||||
DomainEvent::WrapUpRequested {
|
||||
wrapup_id,
|
||||
user_id,
|
||||
start_date,
|
||||
end_date,
|
||||
} => {
|
||||
super::handle_requested::execute(
|
||||
&self.ctx,
|
||||
wrapup_id.clone(),
|
||||
user_id.as_ref().map(|u| u.value()),
|
||||
*start_date,
|
||||
*end_date,
|
||||
)
|
||||
.await
|
||||
}
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user