From 0b47282547f5447c9184af7a137cd3b1531dd4c3 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Wed, 8 Apr 2026 03:05:50 +0200 Subject: [PATCH] feat(common): add SongService application layer --- crates/common/Cargo.toml | 17 +++++++++++++++++ crates/common/src/lib.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 crates/common/Cargo.toml create mode 100644 crates/common/src/lib.rs diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml new file mode 100644 index 0000000..6650ce8 --- /dev/null +++ b/crates/common/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "common" +version = "0.1.0" +edition = "2024" + +[dependencies] +anyhow = { workspace = true } +reqwest = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } +uuid = { workspace = true } +rand = { workspace = true } +async-trait = { workspace = true } +domain = { path = "../domain" } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs new file mode 100644 index 0000000..ecbd84c --- /dev/null +++ b/crates/common/src/lib.rs @@ -0,0 +1,28 @@ +use domain::{RepositoryError, Song, SongRepositoryPort, SongSummary, StoredSong}; +use uuid::Uuid; + +pub struct SongService { + repo: Box, +} + +impl SongService { + pub fn new(repo: Box) -> Self { + Self { repo } + } + + pub async fn save(&self, song: &Song) -> Result { + self.repo.save(song).await + } + + pub async fn list(&self) -> Result, RepositoryError> { + self.repo.list().await + } + + pub async fn get(&self, id: Uuid) -> Result, RepositoryError> { + self.repo.get(id).await + } + + pub async fn delete(&self, id: Uuid) -> Result<(), RepositoryError> { + self.repo.delete(id).await + } +}