application: config_snapshots, admin, providers, iptv
This commit is contained in:
30
crates/application/src/config_snapshots/save.rs
Normal file
30
crates/application/src/config_snapshots/save.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use domain::models::ChannelConfigSnapshot;
|
||||
use domain::value_objects::ChannelId;
|
||||
use domain::{DomainError, DomainResult};
|
||||
|
||||
use super::commands::SaveSnapshotCommand;
|
||||
use super::deps::ConfigSnapshotDeps;
|
||||
|
||||
/// Save a snapshot of the channel's current schedule config.
|
||||
///
|
||||
/// Flow: find channel -> snapshot its current config -> return snapshot.
|
||||
pub async fn execute(
|
||||
deps: &ConfigSnapshotDeps,
|
||||
cmd: SaveSnapshotCommand,
|
||||
) -> DomainResult<ChannelConfigSnapshot> {
|
||||
let channel_id = ChannelId::from(cmd.channel_id);
|
||||
|
||||
let channel = deps
|
||||
.channel_query
|
||||
.find_by_id(channel_id)
|
||||
.await?
|
||||
.ok_or(DomainError::ChannelNotFound(cmd.channel_id))?;
|
||||
|
||||
deps.channel_command
|
||||
.save_config_snapshot(channel_id, channel.schedule_config(), cmd.label)
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/save.rs"]
|
||||
mod tests;
|
||||
Reference in New Issue
Block a user