update
This commit is contained in:
62
src/models/album.rs
Normal file
62
src/models/album.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Album {
|
||||
pub id: Uuid,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub cover_image_id: Option<Uuid>,
|
||||
pub image_count: i64,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
#[serde(default)]
|
||||
pub person_name_cleaned: Option<String>,
|
||||
#[serde(default)]
|
||||
pub tags: Option<String>, // JSON: [tag, ...]
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AlbumInfo {
|
||||
pub id: Uuid,
|
||||
pub title: String,
|
||||
pub document: String,
|
||||
pub description: Option<String>,
|
||||
pub cover_image_id: Option<String>,
|
||||
pub image_count: i64,
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct AlbumWithImages {
|
||||
pub album: Album,
|
||||
pub images: Vec<super::image::Image>,
|
||||
pub image_count: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct CreateAlbum {
|
||||
pub title: String,
|
||||
pub document: String,
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct AlbumIndex {
|
||||
pub title: String,
|
||||
pub images: Vec<String>,
|
||||
}
|
||||
|
||||
/// 相册完整元数据(含扩展字段)
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AlbumMeta {
|
||||
pub id: String,
|
||||
pub title: Option<String>,
|
||||
pub person_name_original: Option<String>,
|
||||
pub person_name_cleaned: Option<String>,
|
||||
pub tags: Option<String>,
|
||||
pub all_words: Option<String>,
|
||||
pub raw_title: Option<String>,
|
||||
pub processed_at: Option<String>,
|
||||
pub image_count: Option<i64>,
|
||||
}
|
||||
30
src/models/favorite.rs
Normal file
30
src/models/favorite.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Favorite {
|
||||
pub id: Uuid,
|
||||
pub user_id: String,
|
||||
pub image_id: Uuid,
|
||||
pub album_id: Uuid,
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct CreateFavorite {
|
||||
pub image_id: Uuid,
|
||||
pub album_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct FavoriteWithImage {
|
||||
pub favorite: Favorite,
|
||||
pub image: super::image::Image,
|
||||
pub album_title: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct FavoriteStatus {
|
||||
pub is_favorited: bool,
|
||||
pub favorite_id: Option<Uuid>,
|
||||
}
|
||||
30
src/models/image.rs
Normal file
30
src/models/image.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Image {
|
||||
pub id: Uuid,
|
||||
pub album_id: Uuid,
|
||||
pub filename: String,
|
||||
pub original_url: Option<String>,
|
||||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub file_size: i64,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub mime_type: String,
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct CreateImage {
|
||||
pub album_id: Uuid,
|
||||
pub filename: String,
|
||||
pub original_url: Option<String>,
|
||||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub file_size: i64,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub mime_type: String,
|
||||
}
|
||||
13
src/models/mod.rs
Normal file
13
src/models/mod.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
pub mod album;
|
||||
pub mod image;
|
||||
pub mod person;
|
||||
pub mod tag;
|
||||
pub mod favorite;
|
||||
pub mod recommend;
|
||||
|
||||
pub use album::*;
|
||||
pub use image::*;
|
||||
pub use person::*;
|
||||
pub use tag::*;
|
||||
pub use favorite::*;
|
||||
pub use recommend::*;
|
||||
53
src/models/person.rs
Normal file
53
src/models/person.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use super::album::AlbumInfo;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Person {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub total_albums: i64,
|
||||
pub total_images: i64,
|
||||
pub original_names: Option<String>,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PersonAlias {
|
||||
pub id: i64,
|
||||
pub person_id: i64,
|
||||
pub alias_type: String,
|
||||
pub alias_name: String,
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PersonWithAlbums {
|
||||
pub person: Person,
|
||||
pub albums: Vec<AlbumInfo>,
|
||||
pub album_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PersonWithCounts {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub total_albums: i64,
|
||||
pub total_images: i64,
|
||||
pub aliases: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PersonListResponse {
|
||||
pub persons: Vec<PersonWithCounts>,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct SearchPersonResponse {
|
||||
pub person: Option<PersonWithCounts>,
|
||||
pub albums: Vec<AlbumInfo>,
|
||||
pub total_albums: usize,
|
||||
}
|
||||
46
src/models/recommend.rs
Normal file
46
src/models/recommend.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// 推荐请求
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct RecommendQuery {
|
||||
pub q: Option<String>,
|
||||
pub limit: Option<usize>,
|
||||
pub context: Option<String>, // 上下文标签(用于共现推荐)
|
||||
}
|
||||
|
||||
/// 推荐条目(通用)
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct RecommendItem {
|
||||
pub value: String,
|
||||
pub label: String,
|
||||
pub score: f64,
|
||||
pub count: Option<i64>,
|
||||
pub source: String, // "tag" | "person" | "co-occurrence" | "popular"
|
||||
}
|
||||
|
||||
/// 推荐响应
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct RecommendResponse {
|
||||
pub items: Vec<RecommendItem>,
|
||||
pub total: usize,
|
||||
pub category: String, // "tags" | "persons" | "related"
|
||||
}
|
||||
|
||||
/// 标签推荐(带上下文)
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct TagRecommendation {
|
||||
pub tag: String,
|
||||
pub related_tags: Vec<RecommendItem>,
|
||||
pub similar_persons: Vec<RecommendItem>,
|
||||
}
|
||||
|
||||
/// 热门人物
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PopularPerson {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub total_albums: i64,
|
||||
pub total_images: i64,
|
||||
pub top_tags: Vec<String>,
|
||||
pub aliases: Vec<String>,
|
||||
}
|
||||
35
src/models/tag.rs
Normal file
35
src/models/tag.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// 标签统计
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct TagStat {
|
||||
pub tag: String,
|
||||
pub count: i64,
|
||||
pub album_count: i64,
|
||||
}
|
||||
|
||||
/// 标签列表响应
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct TagListResponse {
|
||||
pub tags: Vec<TagStat>,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
/// 元数据统计
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct MetadataStats {
|
||||
pub total_persons: i64,
|
||||
pub total_aliases: i64,
|
||||
pub total_albums_with_person: i64,
|
||||
pub total_albums_without_person: i64,
|
||||
pub total_tags: i64,
|
||||
}
|
||||
|
||||
/// 标签共现关系
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct TagCoOccurrence {
|
||||
pub tag: String,
|
||||
pub co_tag: String,
|
||||
pub count: i64,
|
||||
pub score: f64,
|
||||
}
|
||||
Reference in New Issue
Block a user