feat: add sort params to list/search, capo-aware GET /songs/{id}?apply_capo=true

This commit is contained in:
2026-04-08 04:05:57 +02:00
parent 41b9cb3d4c
commit 2558f19960
5 changed files with 92 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
use domain::{RepositoryError, Song, SongRepositoryPort, SongSearchPort, SongSummary, StoredSong};
use domain::{RepositoryError, Song, SongRepositoryPort, SongSearchPort, SongSummary, StoredSong, SortField, SortOrder};
use uuid::Uuid;
pub struct SongService {
@@ -14,8 +14,8 @@ impl SongService {
self.repo.save(song).await
}
pub async fn list(&self) -> Result<Vec<SongSummary>, RepositoryError> {
self.repo.list().await
pub async fn list(&self, sort: SortField, order: SortOrder) -> Result<Vec<SongSummary>, RepositoryError> {
self.repo.list(sort, order).await
}
pub async fn get(&self, id: Uuid) -> Result<Option<Song>, RepositoryError> {
@@ -46,7 +46,7 @@ impl SongSearchService {
Self { search }
}
pub async fn search(&self, query: &str) -> Result<Vec<domain::SongSummary>, domain::RepositoryError> {
self.search.search(query).await
pub async fn search(&self, query: &str, sort: SortField, order: SortOrder) -> Result<Vec<domain::SongSummary>, domain::RepositoryError> {
self.search.search(query, sort, order).await
}
}