1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! Repository trait for MailTrackingValue aggregate
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This trait defines the repository contract for the MailTrackingValue aggregate.
//! Implementation is in the infrastructure layer.
use async_trait::async_trait;
use anyhow::Result;
use uuid::Uuid;
use crate::domain::entity::MailTrackingValue;
/// Pagination parameters for list queries
#[derive(Debug, Clone, Default)]
pub struct MailTrackingValuePaginationParams {
pub page: u32,
pub per_page: u32,
}
impl MailTrackingValuePaginationParams {
pub fn new(page: u32, per_page: u32) -> Self {
Self { page, per_page }
}
pub fn offset(&self) -> u64 {
((self.page.saturating_sub(1)) * self.per_page) as u64
}
pub fn limit(&self) -> u64 {
self.per_page as u64
}
}
/// Paginated result for list queries
#[derive(Debug, Clone)]
pub struct MailTrackingValuePaginatedResult {
pub data: Vec<MailTrackingValue>,
pub total: u64,
pub page: u32,
pub per_page: u32,
}
/// Filter parameters for list queries
#[derive(Debug, Clone, Default)]
pub struct MailTrackingValueFilter {
pub mail_message_id: Option<Uuid>,
pub field: Option<String>,
pub field_desc: Option<String>,
pub field_type: Option<String>,
pub old_value_text: Option<String>,
pub new_value_text: Option<String>,
pub currency_id: Option<Uuid>,
}
impl MailTrackingValueFilter {
/// Check if any filter is set
pub fn has_filters(&self) -> bool {
self.mail_message_id.is_some() || self.field.is_some() || self.field_desc.is_some() || self.field_type.is_some() || self.old_value_text.is_some() || self.new_value_text.is_some() || self.currency_id.is_some()
}
}
/// Repository trait for MailTrackingValue aggregate
///
/// This trait defines the persistence contract for MailTrackingValue entities.
/// Implementations should be in the infrastructure layer.
#[async_trait]
pub trait MailTrackingValueRepository: Send + Sync {
// =========================================================================
// Core CRUD Operations
// =========================================================================
/// Save a new mail_tracking_value entity
async fn save(&self, entity: &MailTrackingValue) -> Result<MailTrackingValue>;
/// Find mail_tracking_value by ID
async fn find_by_id(&self, id: &str) -> Result<Option<MailTrackingValue>>;
/// Find all mail_tracking_value entities
async fn find_all(&self) -> Result<Vec<MailTrackingValue>>;
/// Update mail_tracking_value by ID
async fn update(&self, id: &str, entity: &MailTrackingValue) -> Result<Option<MailTrackingValue>>;
/// Delete mail_tracking_value by ID
async fn delete(&self, id: &str) -> Result<bool>;
// =========================================================================
// Pagination
// =========================================================================
/// List mail_tracking_value with pagination
async fn list(&self, params: MailTrackingValuePaginationParams) -> Result<MailTrackingValuePaginatedResult>;
/// List mail_tracking_value with pagination and filters
async fn list_with_filters(&self, params: MailTrackingValuePaginationParams, filters: MailTrackingValueFilter) -> Result<MailTrackingValuePaginatedResult>;
/// Count all mail_tracking_value entities
async fn count(&self) -> Result<u64>;
/// Count mail_tracking_value entities matching filters
async fn count_with_filters(&self, filters: MailTrackingValueFilter) -> Result<u64>;
/// Check if mail_tracking_value exists by ID
async fn exists(&self, id: &str) -> Result<bool>;
// =========================================================================
// Soft Delete Operations
// =========================================================================
/// Soft delete mail_tracking_value by ID
async fn soft_delete(&self, id: &str) -> Result<bool>;
/// Restore soft-deleted mail_tracking_value by ID
async fn restore(&self, id: &str) -> Result<Option<MailTrackingValue>>;
/// List soft-deleted mail_tracking_value entities
async fn list_deleted(&self, params: MailTrackingValuePaginationParams) -> Result<MailTrackingValuePaginatedResult>;
/// Empty trash (permanently delete all soft-deleted entities)
async fn empty_trash(&self) -> Result<u64>;
// =========================================================================
// Bulk Operations
// =========================================================================
/// Bulk save mail_tracking_value entities
async fn bulk_save(&self, entities: &[MailTrackingValue]) -> Result<Vec<MailTrackingValue>>;
/// Bulk delete by IDs
async fn bulk_delete(&self, ids: &[&str]) -> Result<u64>;
}