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

@@ -3,7 +3,7 @@ use uuid::Uuid;
use crate::{
error::CoreResult,
models::{Album, Media, MediaBundle, User},
models::{Album, FaceRegion, Media, MediaBundle, Person, PersonPermission, Tag, User},
schema::{
AddMediaToAlbumData, CreateAlbumData, CreateUserData, ListMediaOptions, LoginUserData, ShareAlbumData, UpdateAlbumData, UploadMediaData
},
@@ -40,3 +40,48 @@ pub trait AlbumService: Send + Sync {
) -> CoreResult<Album>;
async fn delete_album(&self, album_id: Uuid, user_id: Uuid) -> CoreResult<()>;
}
#[async_trait]
pub trait TagService: Send + Sync {
async fn add_tags_to_media(&self, media_id: Uuid, tag_names: &[String], user_id: Uuid) -> CoreResult<Vec<Tag>>;
async fn remove_tags_from_media(&self, media_id: Uuid, tag_names: &[String], user_id: Uuid) -> CoreResult<()>;
async fn list_tags_for_media(&self, media_id: Uuid, user_id: Uuid) -> CoreResult<Vec<Tag>>;
}
#[async_trait]
pub trait PersonService: Send + Sync {
async fn create_person(&self, name: &str, owner_id: Uuid) -> CoreResult<Person>;
async fn get_person(&self, person_id: Uuid, user_id: Uuid) -> CoreResult<Person>;
async fn list_people(&self, user_id: Uuid) -> CoreResult<Vec<Person>>;
async fn update_person(
&self,
person_id: Uuid,
name: &str,
user_id: Uuid,
) -> CoreResult<Person>;
async fn delete_person(&self, person_id: Uuid, user_id: Uuid) -> CoreResult<()>;
async fn assign_face_to_person(
&self,
face_region_id: Uuid,
person_id: Uuid,
user_id: Uuid,
) -> CoreResult<FaceRegion>;
async fn list_faces_for_media(&self, media_id: Uuid, user_id: Uuid) -> CoreResult<Vec<FaceRegion>>;
async fn share_person(
&self,
person_id: Uuid,
target_user_id: Uuid,
permission: PersonPermission,
owner_id: Uuid,
) -> CoreResult<()>;
async fn unshare_person(
&self,
person_id: Uuid,
target_user_id: Uuid,
owner_id: Uuid,
) -> CoreResult<()>;
}