refactor: group use cases into DDD bounded contexts
Flat use_cases/ (44 files) + monolithic commands.rs/queries.rs split into diary/, movies/, watchlist/, import/, auth/, users/, integrations/, search/, person/, federation/ — each with own commands.rs, queries.rs, and use case modules. Inline tests extracted to sibling tests/ dirs.
This commit is contained in:
45
crates/application/src/diary/get_movie_social_page.rs
Normal file
45
crates/application/src/diary/get_movie_social_page.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
models::{
|
||||
FeedEntry, Movie, MovieProfile, MovieStats,
|
||||
collections::{PageParams, Paginated},
|
||||
},
|
||||
value_objects::MovieId,
|
||||
};
|
||||
|
||||
use crate::{context::AppContext, diary::queries::GetMovieSocialPageQuery};
|
||||
|
||||
pub struct MovieSocialPageResult {
|
||||
pub movie: Movie,
|
||||
pub stats: MovieStats,
|
||||
pub reviews: Paginated<FeedEntry>,
|
||||
pub profile: Option<MovieProfile>,
|
||||
}
|
||||
|
||||
pub async fn execute(
|
||||
ctx: &AppContext,
|
||||
query: GetMovieSocialPageQuery,
|
||||
) -> Result<MovieSocialPageResult, DomainError> {
|
||||
let movie_id = MovieId::from_uuid(query.movie_id);
|
||||
let page = PageParams::new(Some(query.limit), Some(query.offset))?;
|
||||
|
||||
let movie = ctx
|
||||
.repos
|
||||
.movie
|
||||
.get_movie_by_id(&movie_id)
|
||||
.await?
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Movie {}", query.movie_id)))?;
|
||||
|
||||
let (stats, reviews, profile) = tokio::try_join!(
|
||||
ctx.repos.diary.get_movie_stats(&movie_id),
|
||||
ctx.repos.diary.get_movie_social_feed(&movie_id, &page),
|
||||
ctx.repos.movie_profile.get_by_movie_id(&movie_id),
|
||||
)?;
|
||||
|
||||
Ok(MovieSocialPageResult {
|
||||
movie,
|
||||
stats,
|
||||
reviews,
|
||||
profile,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user