93 lines
2.0 KiB
Rust
93 lines
2.0 KiB
Rust
use serde::Deserialize;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]
|
|
#[sqlx(rename_all = "lowercase")]
|
|
#[sqlx(type_name = "TEXT")]
|
|
pub enum Role {
|
|
User,
|
|
Admin,
|
|
}
|
|
|
|
impl Role {
|
|
pub fn as_str(&self) -> &'static str {
|
|
match self {
|
|
Role::User => "user",
|
|
Role::Admin => "admin",
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct Media {
|
|
pub id: uuid::Uuid,
|
|
pub owner_id: uuid::Uuid,
|
|
pub storage_path: String,
|
|
pub original_filename: String,
|
|
pub mime_type: String,
|
|
pub hash: String,
|
|
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
pub extracted_location: Option<String>,
|
|
pub width: Option<i32>,
|
|
pub height: Option<i32>,
|
|
}
|
|
|
|
#[derive(Clone, sqlx::FromRow)]
|
|
pub struct User {
|
|
pub id: uuid::Uuid,
|
|
pub username: String,
|
|
pub email: String,
|
|
pub hashed_password: String,
|
|
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
pub updated_at: chrono::DateTime<chrono::Utc>,
|
|
|
|
pub role: Role,
|
|
pub storage_quota: i64, // in bytes
|
|
pub storage_used: i64, // in bytes
|
|
}
|
|
|
|
pub struct Album {
|
|
pub id: uuid::Uuid,
|
|
pub owner_id: uuid::Uuid,
|
|
pub name: String,
|
|
pub description: Option<String>,
|
|
pub is_public: bool,
|
|
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
pub updated_at: chrono::DateTime<chrono::Utc>,
|
|
}
|
|
|
|
pub struct Person {
|
|
pub id: uuid::Uuid,
|
|
pub owner_id: uuid::Uuid,
|
|
pub name: String,
|
|
pub thumbnail_media_id: Option<uuid::Uuid>,
|
|
}
|
|
|
|
pub struct FaceRegion {
|
|
pub id: uuid::Uuid,
|
|
pub media_id: uuid::Uuid,
|
|
pub person_id: Option<uuid::Uuid>,
|
|
|
|
pub x_min: f32,
|
|
pub y_min: f32,
|
|
pub x_max: f32,
|
|
pub y_max: f32,
|
|
}
|
|
|
|
pub struct AlbumMedia {
|
|
pub album_id: uuid::Uuid,
|
|
pub media_id: uuid::Uuid,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, sqlx::Type, PartialEq, Eq, Deserialize)]
|
|
#[sqlx(rename_all = "lowercase")]
|
|
#[sqlx(type_name = "album_permission")]
|
|
pub enum AlbumPermission {
|
|
View,
|
|
Contribute,
|
|
}
|
|
|
|
pub struct AlbumShare {
|
|
pub album_id: uuid::Uuid,
|
|
pub user_id: uuid::Uuid,
|
|
pub permission: AlbumPermission,
|
|
}
|