This commit is contained in:
Kasper Juul Hermansen 2022-10-16 14:06:07 +02:00
parent 78b9732ca1
commit c58c888725
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
2 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1 @@
# Cibus Backend # Cibus Backend
Some text

View File

@ -1,5 +1,6 @@
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
use anyhow::Context;
use axum::async_trait; use axum::async_trait;
use como_core::projects::ProjectService; use como_core::projects::ProjectService;
use como_domain::projects::{ use como_domain::projects::{
@ -16,6 +17,12 @@ impl DefaultProjectService {
} }
} }
impl Default for DefaultProjectService {
fn default() -> Self {
Self::new()
}
}
#[async_trait] #[async_trait]
impl ProjectService for DefaultProjectService { impl ProjectService for DefaultProjectService {
async fn get_project(&self, _query: GetProjectQuery) -> anyhow::Result<ProjectDto> { async fn get_project(&self, _query: GetProjectQuery) -> anyhow::Result<ProjectDto> {
@ -38,6 +45,12 @@ impl MemoryProjectService {
} }
} }
impl Default for MemoryProjectService {
fn default() -> Self {
Self::new()
}
}
#[async_trait] #[async_trait]
impl ProjectService for MemoryProjectService { impl ProjectService for MemoryProjectService {
async fn get_project(&self, query: GetProjectQuery) -> anyhow::Result<ProjectDto> { async fn get_project(&self, query: GetProjectQuery) -> anyhow::Result<ProjectDto> {
@ -45,7 +58,7 @@ impl ProjectService for MemoryProjectService {
if let Some(item_id) = query.item_id { if let Some(item_id) = query.item_id {
Ok(ps Ok(ps
.get(&item_id.to_string()) .get(&item_id.to_string())
.ok_or(anyhow::anyhow!("could not find project"))? .context("could not find project")?
.clone()) .clone())
} else { } else {
Err(anyhow::anyhow!("could not find project")) Err(anyhow::anyhow!("could not find project"))