feat: add SongSearchService and GET /songs?q= search endpoint
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use domain::{RepositoryError, Song, SongRepositoryPort, SongSummary, StoredSong};
|
||||
use domain::{RepositoryError, Song, SongRepositoryPort, SongSearchPort, SongSummary, StoredSong};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct SongService {
|
||||
@@ -26,3 +26,17 @@ impl SongService {
|
||||
self.repo.delete(id).await
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SongSearchService {
|
||||
search: Box<dyn SongSearchPort>,
|
||||
}
|
||||
|
||||
impl SongSearchService {
|
||||
pub fn new(search: Box<dyn SongSearchPort>) -> Self {
|
||||
Self { search }
|
||||
}
|
||||
|
||||
pub async fn search(&self, query: &str) -> Result<Vec<domain::SongSummary>, domain::RepositoryError> {
|
||||
self.search.search(query).await
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user