Implemented a domain layer, because the API DTO's where getting bloated.

This commit is contained in:
2026-09-26 17:22:10 +02:00
parent 04debfba7b
commit 4737bd5c81
24 changed files with 1103 additions and 538 deletions
+9
View File
@@ -3,6 +3,15 @@ pub enum Upsert<T> {
Updated(T),
}
impl<T> Upsert<T> {
pub fn try_map<U, E>(self, f: impl FnOnce(T) -> Result<U, E>) -> Result<Upsert<U>, E> {
Ok(match self {
Self::Created(value) => Upsert::Created(f(value)?),
Self::Updated(value) => Upsert::Updated(f(value)?),
})
}
}
pub enum Delete {
Deleted,
NotFound,
@@ -5,7 +5,7 @@ use crate::database::{
dtos::recurring_transaction::RecurringTransactionRow,
};
pub async fn query_scheduled_transactions<'e, E>(
pub async fn query_recurring_transactions<'e, E>(
executor: E,
) -> Result<Vec<RecurringTransactionRow>, sqlx::Error>
where
@@ -32,7 +32,7 @@ where
.await
}
pub async fn get_scheduled_transaction_by_id<'e, E>(
pub async fn get_recurring_transaction_by_id<'e, E>(
executor: E,
id: Uuid,
) -> Result<Option<RecurringTransactionRow>, sqlx::Error>
@@ -61,7 +61,7 @@ where
.await
}
pub async fn upsert_scheduled_transaction<'e, E>(
pub async fn upsert_recurring_transaction<'e, E>(
executor: E,
transaction: RecurringTransactionRow,
) -> Result<Upsert<RecurringTransactionRow>, sqlx::Error>
@@ -135,7 +135,7 @@ where
}
}
pub async fn delete_scheduled_transaction_by_id<'e, E>(
pub async fn delete_recurring_transaction_by_id<'e, E>(
executor: E,
id: Uuid,
) -> Result<Delete, sqlx::Error>