diff --git a/src-tauri/src/services/cache/repo.rs b/src-tauri/src/services/cache/repo.rs index 341f78f..1cbef0f 100644 --- a/src-tauri/src/services/cache/repo.rs +++ b/src-tauri/src/services/cache/repo.rs @@ -45,7 +45,13 @@ pub trait CacheRepo: Send + Sync + 'static { } pub struct CacheRepoImpl { - pub db: DatabaseConnection, + db: DatabaseConnection, +} + +impl CacheRepoImpl { + pub fn new(db: DatabaseConnection) -> Self { + Self { db } + } } #[async_trait::async_trait] diff --git a/src-tauri/src/services/cache/service.rs b/src-tauri/src/services/cache/service.rs index 8039a86..48123c1 100644 --- a/src-tauri/src/services/cache/service.rs +++ b/src-tauri/src/services/cache/service.rs @@ -53,7 +53,7 @@ impl CacheServiceImpl { pub fn new(db: DatabaseConnection) -> Self { Self { db: db.clone(), - repo: Arc::new(super::repo::CacheRepoImpl { db }), + repo: Arc::new(super::repo::CacheRepoImpl::new(db)), } } } diff --git a/src-tauri/src/services/transaction/category/repo.rs b/src-tauri/src/services/transaction/category/repo.rs index 3f8cdcd..d0a79f9 100644 --- a/src-tauri/src/services/transaction/category/repo.rs +++ b/src-tauri/src/services/transaction/category/repo.rs @@ -2,8 +2,8 @@ use std::sync::Arc; use crate::{ db::{ - entities::category::{ActiveModel as CategoryActiveModel, Entity as CategoryEntity}, Db, + entities::category::{ActiveModel as CategoryActiveModel, Entity as CategoryEntity}, }, services::transaction::category::{ Category, CategoryServiceError, CategoryServiceResult, CategoryWithParent, @@ -22,7 +22,7 @@ pub trait CategoryRepoService: Send + Sync + 'static { async fn get_category(&self, id: i64) -> Result>; async fn create_category(&self, request: CreateCategoryRequest) -> Result; async fn create_category_with_tx(&self, request: CreateCategoryRequest, tx: &Db) - -> Result; + -> Result; async fn update_category(&self, id: i64, request: UpdateCategoryRequest) -> Result<()>; async fn update_category_with_tx( &self, @@ -35,7 +35,13 @@ pub trait CategoryRepoService: Send + Sync + 'static { #[derive(Clone)] pub struct CategoryRepoServiceImpl { - pub db: DatabaseConnection, + db: DatabaseConnection, +} + +impl CategoryRepoServiceImpl { + pub fn new(db: DatabaseConnection) -> Self { + Self { db } + } } struct CategorySelfRefLink; diff --git a/src-tauri/src/services/transaction/category/service.rs b/src-tauri/src/services/transaction/category/service.rs index 1081894..e38675e 100644 --- a/src-tauri/src/services/transaction/category/service.rs +++ b/src-tauri/src/services/transaction/category/service.rs @@ -6,8 +6,8 @@ use thiserror::Error; use crate::{ db::{Db, DbServiceError}, services::transaction::category::{ - repo::{CategoryRepoService, CategoryRepoServiceImpl}, Category, CategoryWithParent, CreateCategoryRequest, UpdateCategoryRequest, + repo::{CategoryRepoService, CategoryRepoServiceImpl}, }, }; @@ -39,7 +39,7 @@ pub trait CategoryService: Send + Sync + 'static { async fn get_category(&self, id: i64) -> Result>; async fn create_category(&self, request: CreateCategoryRequest) -> Result; async fn create_category_with_tx(&self, request: CreateCategoryRequest, tx: &Db) - -> Result; + -> Result; async fn update_category(&self, id: i64, request: UpdateCategoryRequest) -> Result<()>; async fn update_category_with_tx( &self, @@ -62,7 +62,7 @@ impl CategoryServiceImpl { pub fn new(db: DatabaseConnection) -> Self { Self { db: db.clone(), - category_repo: Arc::new(CategoryRepoServiceImpl { db }), + category_repo: Arc::new(CategoryRepoServiceImpl::new(db)), } } } diff --git a/src-tauri/src/services/transaction/tag/repo.rs b/src-tauri/src/services/transaction/tag/repo.rs index 178aa2b..d7160aa 100644 --- a/src-tauri/src/services/transaction/tag/repo.rs +++ b/src-tauri/src/services/transaction/tag/repo.rs @@ -1,5 +1,6 @@ use crate::{ db::{ + Db, entities::{ tag::{ActiveModel as TagActiveModel, Entity as TagEntity}, transaction_tag::{ @@ -7,7 +8,6 @@ use crate::{ Entity as TransactionTagEntity, }, }, - Db, }, services::transaction::tag::{ CreateTagRequest, Tag, TagServiceError, TagServiceResult, UpdateTagRequest, @@ -45,7 +45,13 @@ pub trait TagRepoService: Send + Sync + 'static { #[derive(Clone)] pub struct TagRepoServiceImpl { - pub db: DatabaseConnection, + db: DatabaseConnection, +} + +impl TagRepoServiceImpl { + pub fn new(db: DatabaseConnection) -> Self { + Self { db } + } } #[async_trait::async_trait] diff --git a/src-tauri/src/services/transaction/tag/service.rs b/src-tauri/src/services/transaction/tag/service.rs index b00c743..37d04a0 100644 --- a/src-tauri/src/services/transaction/tag/service.rs +++ b/src-tauri/src/services/transaction/tag/service.rs @@ -6,8 +6,8 @@ use thiserror::Error; use crate::{ db::{Db, DbServiceError}, services::transaction::tag::{ - repo::{TagRepoService, TagRepoServiceImpl}, CreateTagRequest, Tag, UpdateTagRequest, + repo::{TagRepoService, TagRepoServiceImpl}, }, }; @@ -67,7 +67,7 @@ impl TagServiceImpl { pub fn new(db: DatabaseConnection) -> Self { Self { db: db.clone(), - tag_repo: Arc::new(TagRepoServiceImpl { db }), + tag_repo: Arc::new(TagRepoServiceImpl::new(db)), } } }