feat: Implement person and tag management services

- Added `Person` and `Tag` models to the core library.
- Created `PersonService` and `TagService` traits with implementations for managing persons and tags.
- Introduced repositories for `Person`, `Tag`, `FaceRegion`, and `PersonShare` with PostgreSQL support.
- Updated authorization logic to include permissions for accessing and editing persons.
- Enhanced the schema to support new models and relationships.
- Implemented database migrations for new tables related to persons and tags.
- Added request and response structures for API interactions with persons and tags.
This commit is contained in:
2025-11-15 11:18:11 +01:00
parent 370d55f0b3
commit 4675285603
26 changed files with 1465 additions and 18 deletions

View File

@@ -93,6 +93,7 @@ pub struct Album {
pub updated_at: chrono::DateTime<chrono::Utc>,
}
#[derive(Clone, Debug)]
pub struct Person {
pub id: uuid::Uuid,
pub owner_id: uuid::Uuid,
@@ -100,6 +101,7 @@ pub struct Person {
pub thumbnail_media_id: Option<uuid::Uuid>,
}
#[derive(Clone, Debug)]
pub struct FaceRegion {
pub id: uuid::Uuid,
pub media_id: uuid::Uuid,
@@ -150,4 +152,40 @@ pub struct AlbumShare {
pub struct MediaBundle {
pub media: Media,
pub metadata: Vec<MediaMetadata>,
}
#[derive(Clone, Debug)]
pub struct Tag {
pub id: uuid::Uuid,
pub name: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
pub enum PersonPermission {
View,
CanUse,
}
impl PersonPermission {
pub fn as_str(&self) -> &'static str {
match self {
PersonPermission::View => "view",
PersonPermission::CanUse => "can_use",
}
}
}
impl From<&str> for PersonPermission {
fn from(s: &str) -> Self {
match s {
"can_use" => PersonPermission::CanUse,
_ => PersonPermission::View,
}
}
}
pub struct PersonShare {
pub person_id: uuid::Uuid,
pub user_id: uuid::Uuid,
pub permission: PersonPermission,
}