Unified repo references.

This commit is contained in:
Rogier Reerink
2026-10-08 15:32:19 +02:00
parent 15b229b0de
commit c88cfac8a0
7 changed files with 52 additions and 52 deletions
+7 -7
View File
@@ -10,7 +10,7 @@ use super::{
use crate::{
error::AppError,
repository::{
accounts as repository,
self,
dtos::{Delete, Upsert},
},
};
@@ -33,11 +33,11 @@ pub struct QueryParams {
pub offset: Option<u64>,
}
impl TryFrom<QueryParams> for repository::Query {
impl TryFrom<QueryParams> for repository::accounts::Query {
type Error = AppError;
fn try_from(query: QueryParams) -> Result<Self, Self::Error> {
Ok(repository::Query {
Ok(repository::accounts::Query {
name: query.name,
limit: Some(query.limit.unwrap_or(20)),
offset: query.offset,
@@ -52,7 +52,7 @@ async fn list_accounts(
State(pool): State<PgPool>,
Query(query): Query<QueryParams>,
) -> Result<Json<Vec<AccountResponse>>, AppError> {
let accounts = repository::list(&pool, query.try_into()?)
let accounts = repository::accounts::list(&pool, query.try_into()?)
.await?
.into_iter()
.map(AccountResponse::from)
@@ -67,7 +67,7 @@ async fn get_account(
State(pool): State<PgPool>,
Path(id): Path<Uuid>,
) -> Result<Json<AccountResponse>, AppError> {
let account = repository::get(&pool, id)
let account = repository::accounts::get(&pool, id)
.await?
.ok_or(AppError::NotFound)?;
@@ -83,7 +83,7 @@ async fn upsert_account(
) -> Result<(StatusCode, Json<AccountResponse>), AppError> {
let account = account.into_domain(id)?;
let (status, account) = match repository::upsert(&pool, account).await? {
let (status, account) = match repository::accounts::upsert(&pool, account).await? {
Upsert::Created(account) => (StatusCode::CREATED, account),
Upsert::Updated(account) => (StatusCode::OK, account),
};
@@ -97,7 +97,7 @@ async fn delete_account(
Path(id): Path<Uuid>,
State(pool): State<PgPool>,
) -> Result<StatusCode, AppError> {
match repository::delete(&pool, id).await? {
match repository::accounts::delete(&pool, id).await? {
Delete::Deleted => Ok(StatusCode::NO_CONTENT),
Delete::NotFound => Err(AppError::NotFound),
}