feat: add SongSearchService and GET /songs?q= search endpoint

This commit is contained in:
2026-04-08 03:35:33 +02:00
parent c3b7cb78ab
commit 377fe957bc
9 changed files with 98 additions and 12 deletions

View File

@@ -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
}
}