application: schedule bounded context

This commit is contained in:
2026-07-12 02:02:23 +02:00
parent 6fd47f2d93
commit ef86a967cd
21 changed files with 608 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
use chrono::Utc;
use domain::events::DomainEvent;
use domain::models::GeneratedSchedule;
use domain::value_objects::ChannelId;
use domain::DomainResult;
use super::commands::GenerateScheduleCommand;
use super::deps::ScheduleDeps;
/// Generate a new 7-day schedule for a channel.
///
/// Delegates the heavy lifting to `ScheduleEngineService::generate_schedule`,
/// then publishes a `ScheduleGenerated` domain event.
pub async fn execute(
deps: &ScheduleDeps,
cmd: GenerateScheduleCommand,
) -> DomainResult<GeneratedSchedule> {
let channel_id = ChannelId::from(cmd.channel_id);
let schedule = deps
.schedule_engine
.generate_schedule(channel_id, Utc::now())
.await?;
deps.event_publisher
.publish(DomainEvent::ScheduleGenerated {
channel_id,
schedule_id: schedule.id(),
})
.await?;
Ok(schedule)
}
#[cfg(test)]
#[path = "tests/generate.rs"]
mod tests;