collapse 20 pass-through use cases; handlers call ports directly
delete get/list/list_by_owner channels, get_settings/activity_log admin, get_item/get_sync_status/list_collections/list_seasons/list_shows/list_genres library, get/list/delete providers, get/list/patch_label config_snapshots, get_active/list_history/delete_after schedule — all single-delegation. remove ChannelQueryDeps, LibraryQueryDeps, deleted query/command structs. add direct port fields to AppState. update MCP crate accordingly.
This commit is contained in:
@@ -5,14 +5,8 @@ use api_types::{
|
||||
ChannelResponse, ConfigSnapshotResponse, CreateChannelRequest, PatchSnapshotRequest,
|
||||
UpdateChannelRequest,
|
||||
};
|
||||
use application::channels::{
|
||||
CreateChannelCommand, DeleteChannelCommand, GetChannelQuery, ListByOwnerQuery,
|
||||
ListChannelsQuery, UpdateChannelCommand,
|
||||
};
|
||||
use application::config_snapshots::{
|
||||
GetSnapshotQuery, ListSnapshotsQuery, PatchLabelCommand, RestoreSnapshotCommand,
|
||||
SaveSnapshotCommand,
|
||||
};
|
||||
use application::channels::{CreateChannelCommand, DeleteChannelCommand, UpdateChannelCommand};
|
||||
use application::config_snapshots::{RestoreSnapshotCommand, SaveSnapshotCommand};
|
||||
use domain::DomainError;
|
||||
|
||||
use crate::errors::AppError;
|
||||
@@ -23,8 +17,7 @@ pub async fn list_channels(
|
||||
State(state): State<AppState>,
|
||||
CurrentUser(_user): CurrentUser,
|
||||
) -> Result<Json<Vec<ChannelResponse>>, AppError> {
|
||||
let channels =
|
||||
application::channels::list::execute(&state.channel_query_deps, ListChannelsQuery).await?;
|
||||
let channels = state.channel_query.find_all().await?;
|
||||
Ok(Json(channels.into_iter().map(ChannelResponse::from).collect()))
|
||||
}
|
||||
|
||||
@@ -32,11 +25,7 @@ pub async fn list_my_channels(
|
||||
State(state): State<AppState>,
|
||||
CurrentUser(user): CurrentUser,
|
||||
) -> Result<Json<Vec<ChannelResponse>>, AppError> {
|
||||
let query = ListByOwnerQuery {
|
||||
owner_id: user.id(),
|
||||
};
|
||||
let channels =
|
||||
application::channels::list_by_owner::execute(&state.channel_query_deps, query).await?;
|
||||
let channels = state.channel_query.find_by_owner(user.id()).await?;
|
||||
Ok(Json(channels.into_iter().map(ChannelResponse::from).collect()))
|
||||
}
|
||||
|
||||
@@ -59,10 +48,9 @@ pub async fn get_channel(
|
||||
CurrentUser(_user): CurrentUser,
|
||||
Path(id): Path<uuid::Uuid>,
|
||||
) -> Result<Json<ChannelResponse>, AppError> {
|
||||
let query = GetChannelQuery {
|
||||
channel_id: id.into(),
|
||||
};
|
||||
let channel = application::channels::get::execute(&state.channel_query_deps, query)
|
||||
let channel = state
|
||||
.channel_query
|
||||
.find_by_id(id.into())
|
||||
.await?
|
||||
.ok_or_else(|| AppError(DomainError::NotFound(format!("Channel {id} not found"))))?;
|
||||
Ok(Json(ChannelResponse::from(channel)))
|
||||
@@ -119,10 +107,7 @@ pub async fn list_snapshots(
|
||||
CurrentUser(_user): CurrentUser,
|
||||
Path(id): Path<uuid::Uuid>,
|
||||
) -> Result<Json<Vec<ConfigSnapshotResponse>>, AppError> {
|
||||
let query = ListSnapshotsQuery {
|
||||
channel_id: id.into(),
|
||||
};
|
||||
let snaps = application::config_snapshots::list::execute(&state.config_snapshot_deps, query).await?;
|
||||
let snaps = state.channel_query.list_config_snapshots(id.into()).await?;
|
||||
Ok(Json(snaps.into_iter().map(ConfigSnapshotResponse::from).collect()))
|
||||
}
|
||||
|
||||
@@ -131,11 +116,9 @@ pub async fn get_snapshot(
|
||||
CurrentUser(_user): CurrentUser,
|
||||
Path((id, snapshot_id)): Path<(uuid::Uuid, uuid::Uuid)>,
|
||||
) -> Result<Json<ConfigSnapshotResponse>, AppError> {
|
||||
let query = GetSnapshotQuery {
|
||||
channel_id: id.into(),
|
||||
snapshot_id: snapshot_id.into(),
|
||||
};
|
||||
let snap = application::config_snapshots::get::execute(&state.config_snapshot_deps, query)
|
||||
let snap = state
|
||||
.channel_query
|
||||
.get_config_snapshot(id.into(), snapshot_id.into())
|
||||
.await?
|
||||
.ok_or_else(|| AppError(DomainError::NotFound("Snapshot not found".into())))?;
|
||||
Ok(Json(ConfigSnapshotResponse::from(snap)))
|
||||
@@ -147,15 +130,12 @@ pub async fn patch_snapshot(
|
||||
Path((id, snapshot_id)): Path<(uuid::Uuid, uuid::Uuid)>,
|
||||
Json(req): Json<PatchSnapshotRequest>,
|
||||
) -> Result<Json<ConfigSnapshotResponse>, AppError> {
|
||||
let cmd = PatchLabelCommand {
|
||||
channel_id: id.into(),
|
||||
snapshot_id: snapshot_id.into(),
|
||||
label: req.label,
|
||||
};
|
||||
let snap =
|
||||
application::config_snapshots::patch_label::execute(&state.config_snapshot_deps, cmd)
|
||||
.await?
|
||||
.ok_or_else(|| AppError(DomainError::NotFound("Snapshot not found".into())))?;
|
||||
let snap = state
|
||||
.channel_command_deps
|
||||
.channel_command
|
||||
.patch_config_snapshot_label(id.into(), snapshot_id.into(), req.label)
|
||||
.await?
|
||||
.ok_or_else(|| AppError(DomainError::NotFound("Snapshot not found".into())))?;
|
||||
Ok(Json(ConfigSnapshotResponse::from(snap)))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user