separation of database (#1)

Reviewed-on: #1
This commit is contained in:
2025-11-03 02:26:19 +00:00
parent 8b98df745c
commit 39ee8d52a4
21 changed files with 407 additions and 140 deletions

View File

@@ -2,6 +2,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use libertas_core::{
config::Config,
error::{CoreError, CoreResult},
models::{Role, User},
repositories::UserRepository,
@@ -16,6 +17,7 @@ pub struct UserServiceImpl {
repo: Arc<dyn UserRepository>,
hasher: Arc<dyn PasswordHasher>,
tokenizer: Arc<dyn TokenGenerator>,
config: Arc<Config>,
}
impl UserServiceImpl {
@@ -23,11 +25,13 @@ impl UserServiceImpl {
repo: Arc<dyn UserRepository>,
hasher: Arc<dyn PasswordHasher>,
tokenizer: Arc<dyn TokenGenerator>,
config: Arc<Config>,
) -> Self {
Self {
repo,
hasher,
tokenizer,
config,
}
}
}
@@ -50,6 +54,9 @@ impl UserService for UserServiceImpl {
let hashed_password = self.hasher.hash_password(data.password).await?;
let quota_gb = self.config.default_storage_quota_gb.unwrap_or(10);
let storage_quota = (quota_gb * 1024 * 1024 * 1024) as i64;
let user = User {
id: Uuid::new_v4(),
username: data.username.to_string(),
@@ -58,7 +65,7 @@ impl UserService for UserServiceImpl {
created_at: chrono::Utc::now(),
updated_at: chrono::Utc::now(),
role: Role::User,
storage_quota: 10 * 1024 * 1024 * 1024, // 10 GB
storage_quota,
storage_used: 0,
};