refactor(watchlist): WatchlistAddDeps, scoped Arc deps
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
ports::WatchlistRepository,
|
||||
value_objects::{MovieId, UserId},
|
||||
};
|
||||
|
||||
use crate::{context::AppContext, watchlist::queries::IsOnWatchlistQuery};
|
||||
use crate::watchlist::queries::IsOnWatchlistQuery;
|
||||
|
||||
pub async fn execute(ctx: &AppContext, query: IsOnWatchlistQuery) -> Result<bool, DomainError> {
|
||||
pub async fn execute(
|
||||
watchlist: Arc<dyn WatchlistRepository>,
|
||||
query: IsOnWatchlistQuery,
|
||||
) -> Result<bool, DomainError> {
|
||||
let user_id = UserId::from_uuid(query.user_id);
|
||||
let movie_id = MovieId::from_uuid(query.movie_id);
|
||||
ctx.repos.watchlist.contains(&user_id, &movie_id).await
|
||||
watchlist.contains(&user_id, &movie_id).await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user