Initial commit

This commit is contained in:
2024-12-29 12:20:01 +01:00
commit 9ebe9b55bd
87 changed files with 21545 additions and 0 deletions

11
backend/entity/Cargo.toml Normal file
View File

@@ -0,0 +1,11 @@
[package]
name = "entity"
version = "0.1.0"
edition = "2024"
[lib]
name = "entity"
path = "mod.rs"
[dependencies]
sea-orm = { version = "1.1.19" }

View File

@@ -0,0 +1,35 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "access_log")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false, column_type = "Binary(16)")]
pub id: Vec<u8>,
pub ip: String,
#[sea_orm(column_type = "Binary(16)")]
pub file_id: Vec<u8>,
pub date_time: DateTime,
pub successful: i8,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::file::Entity",
from = "Column::FileId",
to = "super::file::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
File,
}
impl Related<super::file::Entity> for Entity {
fn to() -> RelationDef {
Relation::File.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

31
backend/entity/file.rs Normal file
View File

@@ -0,0 +1,31 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "file")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false, column_type = "Binary(16)")]
pub id: Vec<u8>,
#[sea_orm(unique)]
pub hash: String,
pub uploader_ip: String,
pub uploaded_at: DateTime,
pub download_until: DateTime,
#[sea_orm(column_type = "Binary(255)")]
pub encrypted_metadata: Vec<u8>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::access_log::Entity")]
AccessLog,
}
impl Related<super::access_log::Entity> for Entity {
fn to() -> RelationDef {
Relation::AccessLog.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

8
backend/entity/mod.rs Normal file
View File

@@ -0,0 +1,8 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
pub mod prelude;
pub mod access_log;
pub mod file;
pub use prelude::*;

View File

@@ -0,0 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
pub use super::access_log::Entity as AccessLog;
pub use super::file::Entity as File;