importer feature
This commit is contained in:
17
crates/domain/src/models/import_profile.rs
Normal file
17
crates/domain/src/models/import_profile.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use crate::value_objects::{ImportProfileId, UserId};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ImportProfile {
|
||||
pub id: ImportProfileId,
|
||||
pub user_id: UserId,
|
||||
pub name: String,
|
||||
pub field_mappings: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
}
|
||||
|
||||
impl ImportProfile {
|
||||
pub fn new(id: ImportProfileId, user_id: UserId, name: String, field_mappings: String, created_at: NaiveDateTime) -> Self {
|
||||
Self { id, user_id, name, field_mappings, created_at }
|
||||
}
|
||||
}
|
||||
20
crates/domain/src/models/import_session.rs
Normal file
20
crates/domain/src/models/import_session.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use crate::value_objects::{ImportSessionId, UserId};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ImportSession {
|
||||
pub id: ImportSessionId,
|
||||
pub user_id: UserId,
|
||||
pub parsed_data: String,
|
||||
pub field_mappings: Option<String>,
|
||||
pub row_results: Option<String>,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub expires_at: NaiveDateTime,
|
||||
}
|
||||
|
||||
impl ImportSession {
|
||||
pub fn new(id: ImportSessionId, user_id: UserId, parsed_data: String, created_at: NaiveDateTime) -> Self {
|
||||
let expires_at = created_at + chrono::Duration::hours(24);
|
||||
Self { id, user_id, parsed_data, field_mappings: None, row_results: None, created_at, expires_at }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,11 @@ use crate::{
|
||||
},
|
||||
};
|
||||
pub mod collections;
|
||||
pub mod import_session;
|
||||
pub mod import_profile;
|
||||
|
||||
pub use import_session::ImportSession;
|
||||
pub use import_profile::ImportProfile;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub enum SortDirection {
|
||||
|
||||
@@ -5,13 +5,13 @@ use crate::{
|
||||
errors::DomainError,
|
||||
events::{DomainEvent, EventEnvelope},
|
||||
models::{
|
||||
DiaryEntry, DiaryFilter, ExportFormat, FeedEntry, Movie, Review, ReviewHistory, User,
|
||||
UserStats, UserSummary, UserTrends,
|
||||
DiaryEntry, DiaryFilter, ExportFormat, FeedEntry, ImportProfile, ImportSession, Movie,
|
||||
Review, ReviewHistory, User, UserStats, UserSummary, UserTrends,
|
||||
collections::{PageParams, Paginated},
|
||||
},
|
||||
value_objects::{
|
||||
Email, ExternalMetadataId, MovieId, MovieTitle, PasswordHash, PosterPath, PosterUrl,
|
||||
ReleaseYear, ReviewId, UserId, Username,
|
||||
Email, ExternalMetadataId, ImportProfileId, ImportSessionId, MovieId, MovieTitle,
|
||||
PasswordHash, PosterPath, PosterUrl, ReleaseYear, ReviewId, UserId, Username,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -200,3 +200,21 @@ pub trait DiaryExporter: Send + Sync {
|
||||
pub trait EventHandler: Send + Sync {
|
||||
async fn handle(&self, event: &DomainEvent) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait ImportSessionRepository: Send + Sync {
|
||||
async fn create(&self, session: &ImportSession) -> Result<(), DomainError>;
|
||||
async fn get(&self, id: &ImportSessionId, user_id: &UserId) -> Result<Option<ImportSession>, DomainError>;
|
||||
async fn update(&self, session: &ImportSession) -> Result<(), DomainError>;
|
||||
async fn delete(&self, id: &ImportSessionId) -> Result<(), DomainError>;
|
||||
async fn delete_expired(&self) -> Result<u64, DomainError>;
|
||||
async fn delete_expired_for_user(&self, user_id: &UserId) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait ImportProfileRepository: Send + Sync {
|
||||
async fn save(&self, profile: &ImportProfile) -> Result<(), DomainError>;
|
||||
async fn list_for_user(&self, user_id: &UserId) -> Result<Vec<ImportProfile>, DomainError>;
|
||||
async fn get(&self, id: &ImportProfileId, user_id: &UserId) -> Result<Option<ImportProfile>, DomainError>;
|
||||
async fn delete(&self, id: &ImportProfileId) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ macro_rules! uuid_id {
|
||||
uuid_id!(MovieId);
|
||||
uuid_id!(ReviewId);
|
||||
uuid_id!(UserId);
|
||||
uuid_id!(ImportSessionId);
|
||||
uuid_id!(ImportProfileId);
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ExternalMetadataId(String);
|
||||
|
||||
Reference in New Issue
Block a user