refactor (v2): better arch

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-06-07 21:19:54 +02:00
parent 0753f3d256
commit 839308ec19
166 changed files with 8553 additions and 884 deletions

View File

@@ -0,0 +1,28 @@
use domain::{
errors::{DomainError, DomainResult},
note::entity::Note,
user::entity::UserId,
};
use super::queries::GetNoteQuery;
use crate::context::AppContext;
pub async fn execute(ctx: &AppContext, q: GetNoteQuery) -> DomainResult<Note> {
let note_id = domain::note::entity::NoteId::from_uuid(q.note_id);
let user_id = UserId::from_uuid(q.user_id);
let note = ctx
.repos
.note
.find_by_id(&note_id)
.await?
.ok_or_else(|| DomainError::NotFound(format!("note {}", q.note_id)))?;
if note.user_id != user_id {
return Err(DomainError::Forbidden(
"note belongs to another user".into(),
));
}
Ok(note)
}