06ed0455ce
- Schema: all ~15 VARCHAR(36) columns → UUID with DEFAULT gen_random_uuid() - Domain entities: User, Session, DeviceCode, AppPassword, Share → id: Uuid - DTOs: CurrentUser.id → Uuid (API boundary DTOs keep String for JSON) - Auth middleware: parse JWT claims.sub (String) → Uuid at boundary - All repository traits, port traits, service impls updated end-to-end - Handlers: pass Uuid by value (Copy, 16 bytes) instead of String refs - Settings chain: updated_by column → Uuid (was text, caused setup crash) - Removed ~650 lines of String↔Uuid conversion boilerplate - Eliminates per-request heap allocations for ID cloning - 16-byte binary comparison vs 36-byte string comparison in all queries - Native UUID indexing in PostgreSQL (btree on 16 bytes vs 36-char text) 85 files changed, 1090 insertions(+), 1739 deletions(-)
103 lines
3.1 KiB
Rust
Executable File
103 lines
3.1 KiB
Rust
Executable File
use crate::common::errors::DomainError;
|
|
use crate::domain::entities::calendar::Calendar;
|
|
use uuid::Uuid;
|
|
|
|
pub type CalendarRepositoryResult<T> = Result<T, DomainError>;
|
|
|
|
/// Repository interface for Calendar entity operations
|
|
pub trait CalendarRepository: Send + Sync + 'static {
|
|
/// Creates a new calendar
|
|
async fn create_calendar(&self, calendar: Calendar) -> CalendarRepositoryResult<Calendar>;
|
|
|
|
/// Updates an existing calendar
|
|
async fn update_calendar(&self, calendar: Calendar) -> CalendarRepositoryResult<Calendar>;
|
|
|
|
/// Deletes a calendar by ID
|
|
async fn delete_calendar(&self, id: &Uuid) -> CalendarRepositoryResult<()>;
|
|
|
|
/// Finds a calendar by its ID
|
|
async fn find_calendar_by_id(&self, id: &Uuid) -> CalendarRepositoryResult<Calendar>;
|
|
|
|
/// Lists all calendars for a specific user
|
|
async fn list_calendars_by_owner(
|
|
&self,
|
|
owner_id: Uuid,
|
|
) -> CalendarRepositoryResult<Vec<Calendar>>;
|
|
|
|
/// Finds a calendar by name and owner
|
|
async fn find_calendar_by_name_and_owner(
|
|
&self,
|
|
name: &str,
|
|
owner_id: Uuid,
|
|
) -> CalendarRepositoryResult<Calendar>;
|
|
|
|
/// Lists calendars shared with a specific user
|
|
async fn list_calendars_shared_with_user(
|
|
&self,
|
|
user_id: Uuid,
|
|
) -> CalendarRepositoryResult<Vec<Calendar>>;
|
|
|
|
/// List public calendars
|
|
async fn list_public_calendars(
|
|
&self,
|
|
limit: i64,
|
|
offset: i64,
|
|
) -> CalendarRepositoryResult<Vec<Calendar>>;
|
|
|
|
/// Checks if a user has access to a calendar
|
|
async fn user_has_calendar_access(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
user_id: Uuid,
|
|
) -> CalendarRepositoryResult<bool>;
|
|
|
|
/// Gets a custom property for a calendar
|
|
async fn get_calendar_property(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
property_name: &str,
|
|
) -> CalendarRepositoryResult<Option<String>>;
|
|
|
|
/// Sets a custom property for a calendar
|
|
async fn set_calendar_property(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
property_name: &str,
|
|
property_value: &str,
|
|
) -> CalendarRepositoryResult<()>;
|
|
|
|
/// Removes a custom property from a calendar
|
|
async fn remove_calendar_property(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
property_name: &str,
|
|
) -> CalendarRepositoryResult<()>;
|
|
|
|
/// Gets all custom properties for a calendar
|
|
async fn get_calendar_properties(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
) -> CalendarRepositoryResult<std::collections::HashMap<String, String>>;
|
|
|
|
/// Share calendar with another user
|
|
async fn share_calendar(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
user_id: Uuid,
|
|
access_level: &str,
|
|
) -> CalendarRepositoryResult<()>;
|
|
|
|
/// Remove calendar sharing for a user
|
|
async fn remove_calendar_sharing(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
user_id: Uuid,
|
|
) -> CalendarRepositoryResult<()>;
|
|
|
|
/// Get calendar sharing information (who has access to this calendar)
|
|
async fn get_calendar_shares(
|
|
&self,
|
|
calendar_id: &Uuid,
|
|
) -> CalendarRepositoryResult<Vec<(String, String)>>;
|
|
}
|