refactoring hexagonal and clean architecture

This commit is contained in:
Diocrafts
2026-02-08 13:40:23 +01:00
parent 3e4fb67c19
commit a82faa5eaf
101 changed files with 7433 additions and 9721 deletions
+24
View File
@@ -16,4 +16,28 @@ pub trait FavoritesUseCase: Send + Sync {
/// Check if an item is in user's favorites
async fn is_favorite(&self, user_id: &str, item_id: &str, item_type: &str) -> Result<bool>;
}
// ─────────────────────────────────────────────────────
// Outbound port — persistence abstraction
// ─────────────────────────────────────────────────────
/// Puerto secundario (outbound) para persistencia de favoritos.
///
/// Los servicios de aplicación dependen de este trait en lugar de
/// acceder directamente a `PgPool`. La implementación concreta
/// vive en `infrastructure::repositories::pg`.
#[async_trait]
pub trait FavoritesRepositoryPort: Send + Sync + 'static {
/// Obtiene todos los favoritos de un usuario.
async fn get_favorites(&self, user_id: &str) -> Result<Vec<FavoriteItemDto>>;
/// Añade un ítem a favoritos. Devuelve `Ok(())` si ya existía (idempotente).
async fn add_favorite(&self, user_id: &str, item_id: &str, item_type: &str) -> Result<()>;
/// Elimina un ítem de favoritos. Devuelve `true` si existía.
async fn remove_favorite(&self, user_id: &str, item_id: &str, item_type: &str) -> Result<bool>;
/// Comprueba si un ítem está en favoritos.
async fn is_favorite(&self, user_id: &str, item_id: &str, item_type: &str) -> Result<bool>;
}