This commit is contained in:
2025-10-09 22:16:29 +02:00
commit 768f8cb21c
33 changed files with 12047 additions and 0 deletions
+137
View File
@@ -0,0 +1,137 @@
use chrono::NaiveDateTime;
use diesel::prelude::*;
use uuid::Uuid;
use crate::schema::*;
#[derive(Debug, Clone, Queryable, Identifiable)]
#[diesel(table_name = users)]
pub struct User {
pub id: Uuid,
pub username: String,
pub password_hash: String,
pub role: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
}
#[derive(Debug, Insertable)]
#[diesel(table_name = users)]
pub struct NewUser {
pub id: Uuid,
pub username: String,
pub password_hash: String,
pub role: String,
}
#[derive(Debug, Clone, Queryable, Identifiable)]
#[diesel(table_name = folders)]
pub struct Folder {
pub id: Uuid,
pub name: String,
pub parent_id: Option<Uuid>,
pub path_cache: Option<String>,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
}
#[derive(Debug, Insertable)]
#[diesel(table_name = folders)]
pub struct NewFolder {
pub id: Uuid,
pub name: String,
pub parent_id: Option<Uuid>,
pub path_cache: Option<String>,
}
#[derive(Debug, Clone, Queryable, Identifiable, Associations)]
#[diesel(table_name = documents)]
#[diesel(belongs_to(Folder, foreign_key = folder_id))]
pub struct Document {
pub id: Uuid,
pub filename: String,
pub original_name: String,
pub content_type: Option<String>,
pub folder_id: Option<Uuid>,
pub current_version: i32,
pub uploaded_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub deleted_at: Option<NaiveDateTime>,
pub metadata: serde_json::Value,
}
#[derive(Debug, Insertable)]
#[diesel(table_name = documents)]
pub struct NewDocument {
pub id: Uuid,
pub filename: String,
pub original_name: String,
pub content_type: Option<String>,
pub folder_id: Option<Uuid>,
pub current_version: i32,
pub metadata: serde_json::Value,
}
#[derive(Debug, Clone, Queryable, Identifiable, Associations)]
#[diesel(table_name = document_versions)]
#[diesel(belongs_to(Document))]
pub struct DocumentVersion {
pub id: Uuid,
pub document_id: Uuid,
pub version_number: i32,
pub s3_key: String,
pub size_bytes: i64,
pub checksum: String,
pub created_at: NaiveDateTime,
pub operations_summary: serde_json::Value,
}
#[derive(Debug, Insertable)]
#[diesel(table_name = document_versions)]
pub struct NewDocumentVersion {
pub id: Uuid,
pub document_id: Uuid,
pub version_number: i32,
pub s3_key: String,
pub size_bytes: i64,
pub checksum: String,
pub operations_summary: serde_json::Value,
}
#[derive(Debug, Clone, Queryable, Identifiable)]
#[diesel(table_name = tags)]
pub struct Tag {
pub id: Uuid,
pub label: String,
pub color: Option<String>,
pub created_at: NaiveDateTime,
}
#[derive(Debug, Insertable)]
#[diesel(table_name = tags)]
pub struct NewTag {
pub id: Uuid,
pub label: String,
pub color: Option<String>,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Queryable, Associations)]
#[diesel(table_name = document_tags)]
#[diesel(belongs_to(Document))]
#[diesel(belongs_to(Tag))]
#[diesel(primary_key(document_id, tag_id))]
pub struct DocumentTag {
pub document_id: Uuid,
pub tag_id: Uuid,
pub assigned_at: NaiveDateTime,
pub assigned_by: Option<Uuid>,
}
#[derive(Debug, Insertable)]
#[diesel(table_name = document_tags)]
pub struct NewDocumentTag {
pub document_id: Uuid,
pub tag_id: Uuid,
pub assigned_by: Option<Uuid>,
}