feat: wrapup worker handler + auto-generate job

This commit is contained in:
2026-06-02 22:13:08 +02:00
parent ac05cdfeaf
commit 7ef8912d69
9 changed files with 194 additions and 14 deletions

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