refactor: visibility of services
This commit is contained in:
8
src-tauri/src/services/cache/repo.rs
vendored
8
src-tauri/src/services/cache/repo.rs
vendored
@@ -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]
|
||||
|
||||
2
src-tauri/src/services/cache/service.rs
vendored
2
src-tauri/src/services/cache/service.rs
vendored
@@ -53,7 +53,7 @@ impl CacheServiceImpl<super::repo::CacheRepoImpl> {
|
||||
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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Option<CategoryWithParent>>;
|
||||
async fn create_category(&self, request: CreateCategoryRequest) -> Result<i64>;
|
||||
async fn create_category_with_tx(&self, request: CreateCategoryRequest, tx: &Db)
|
||||
-> Result<i64>;
|
||||
-> Result<i64>;
|
||||
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;
|
||||
|
||||
@@ -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<Option<CategoryWithParent>>;
|
||||
async fn create_category(&self, request: CreateCategoryRequest) -> Result<i64>;
|
||||
async fn create_category_with_tx(&self, request: CreateCategoryRequest, tx: &Db)
|
||||
-> Result<i64>;
|
||||
-> Result<i64>;
|
||||
async fn update_category(&self, id: i64, request: UpdateCategoryRequest) -> Result<()>;
|
||||
async fn update_category_with_tx(
|
||||
&self,
|
||||
@@ -62,7 +62,7 @@ impl CategoryServiceImpl<CategoryRepoServiceImpl> {
|
||||
pub fn new(db: DatabaseConnection) -> Self {
|
||||
Self {
|
||||
db: db.clone(),
|
||||
category_repo: Arc::new(CategoryRepoServiceImpl { db }),
|
||||
category_repo: Arc::new(CategoryRepoServiceImpl::new(db)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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<TagRepoServiceImpl> {
|
||||
pub fn new(db: DatabaseConnection) -> Self {
|
||||
Self {
|
||||
db: db.clone(),
|
||||
tag_repo: Arc::new(TagRepoServiceImpl { db }),
|
||||
tag_repo: Arc::new(TagRepoServiceImpl::new(db)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user