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

@@ -5,14 +5,13 @@ use libertas_core::{
error::{CoreError, CoreResult},
};
use libertas_infra::factory::{
build_album_repository, build_album_share_repository, build_database_pool, build_media_metadata_repository, build_media_repository, build_user_repository
build_album_repository, build_album_share_repository, build_database_pool, build_face_region_repository, build_media_metadata_repository, build_media_repository, build_person_repository, build_person_share_repository, build_tag_repository, build_user_repository
};
use crate::{
security::{Argon2Hasher, JwtGenerator},
services::{
album_service::AlbumServiceImpl, media_service::MediaServiceImpl,
user_service::UserServiceImpl,
album_service::AlbumServiceImpl, media_service::MediaServiceImpl, person_service::PersonServiceImpl, tag_service::TagServiceImpl, user_service::UserServiceImpl
},
state::AppState,
};
@@ -31,6 +30,10 @@ pub async fn build_app_state(config: AppConfig) -> CoreResult<AppState> {
let album_share_repo = build_album_share_repository(&config.database, db_pool.clone()).await?;
let media_metadata_repo =
build_media_metadata_repository(&config.database, db_pool.clone()).await?;
let tag_repo = build_tag_repository(&config.database, db_pool.clone()).await?;
let person_repo = build_person_repository(&config.database, db_pool.clone()).await?;
let face_region_repo = build_face_region_repository(&config.database, db_pool.clone()).await?;
let person_share_repo = build_person_share_repository(&config.database, db_pool.clone()).await?;
let hasher = Arc::new(Argon2Hasher::default());
let tokenizer = Arc::new(JwtGenerator::new(config.jwt_secret.clone()));
@@ -51,14 +54,26 @@ pub async fn build_app_state(config: AppConfig) -> CoreResult<AppState> {
));
let album_service = Arc::new(AlbumServiceImpl::new(
album_repo,
media_repo,
media_repo.clone(),
album_share_repo,
));
let tag_service = Arc::new(TagServiceImpl::new(
tag_repo,
media_repo.clone(),
));
let person_service = Arc::new(PersonServiceImpl::new(
person_repo,
face_region_repo,
media_repo.clone(),
person_share_repo,
));
Ok(AppState {
user_service,
media_service,
album_service,
tag_service,
person_service,
token_generator: tokenizer,
nats_client,
config,