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:
@@ -1,4 +1,4 @@
|
||||
use libertas_core::{models::{Album, AlbumPermission, MediaMetadata}};
|
||||
use libertas_core::models::{Album, AlbumPermission, FaceRegion, MediaMetadata, Person, PersonPermission, Tag};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -121,3 +121,78 @@ pub struct MediaDetailsResponse {
|
||||
pub metadata: Vec<MediaMetadataResponse>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct TagResponse {
|
||||
pub id: Uuid,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl From<Tag> for TagResponse {
|
||||
fn from(tag: Tag) -> Self {
|
||||
Self { id: tag.id, name: tag.name }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct MediaTagsRequest {
|
||||
pub tags: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct PersonResponse {
|
||||
pub id: Uuid,
|
||||
pub owner_id: Uuid,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl From<Person> for PersonResponse {
|
||||
fn from(person: Person) -> Self {
|
||||
Self { id: person.id, owner_id: person.owner_id, name: person.name }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct CreatePersonRequest {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdatePersonRequest {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct FaceRegionResponse {
|
||||
pub id: Uuid,
|
||||
pub media_id: Uuid,
|
||||
pub person_id: Option<Uuid>,
|
||||
pub x_min: f32,
|
||||
pub y_min: f32,
|
||||
pub x_max: f32,
|
||||
pub y_max: f32,
|
||||
}
|
||||
|
||||
impl From<FaceRegion> for FaceRegionResponse {
|
||||
fn from(face: FaceRegion) -> Self {
|
||||
Self {
|
||||
id: face.id,
|
||||
media_id: face.media_id,
|
||||
person_id: face.person_id,
|
||||
x_min: face.x_min,
|
||||
y_min: face.y_min,
|
||||
x_max: face.x_max,
|
||||
y_max: face.y_max,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct AssignFaceRequest {
|
||||
pub person_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct SharePersonRequest {
|
||||
pub target_user_id: Uuid,
|
||||
pub permission: PersonPermission,
|
||||
}
|
||||
Reference in New Issue
Block a user