feat: enhance album and media management with update and delete functionalities

This commit is contained in:
2025-11-02 18:46:26 +01:00
parent a36b59a5fb
commit 13bb9e6b3e
14 changed files with 334 additions and 43 deletions

View File

@@ -88,4 +88,38 @@ impl AlbumRepository for PostgresAlbumRepository {
Ok(())
}
async fn update(&self, album: Album) -> CoreResult<()> {
sqlx::query!(
r#"
UPDATE albums
SET name = $1, description = $2, is_public = $3, updated_at = NOW()
WHERE id = $4
"#,
album.name,
album.description,
album.is_public,
album.id
)
.execute(&self.pool)
.await
.map_err(|e| CoreError::Database(e.to_string()))?;
Ok(())
}
async fn delete(&self, id: Uuid) -> CoreResult<()> {
sqlx::query!(
r#"
DELETE FROM albums
WHERE id = $1
"#,
id
)
.execute(&self.pool)
.await
.map_err(|e| CoreError::Database(e.to_string()))?;
Ok(())
}
}

View File

@@ -115,4 +115,19 @@ impl MediaRepository for PostgresMediaRepository {
Ok(())
}
async fn delete(&self, id: Uuid) -> CoreResult<()> {
sqlx::query!(
r#"
DELETE FROM media
WHERE id = $1
"#,
id
)
.execute(&self.pool)
.await
.map_err(|e| CoreError::Database(e.to_string()))?;
Ok(())
}
}