initial commit

This commit is contained in:
Sebastian Hugentobler 2024-07-10 14:30:26 +02:00
commit 8d297920fb
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
27 changed files with 6743 additions and 0 deletions

11
entity/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "entity"
version = "0.1.0"
edition = "2021"
license.workspace = true
authors.workspace = true
repository.workspace = true
[dependencies]
sea-orm = { workspace = true, features = ["with-time", "sqlx-sqlite", "sqlx-postgres", "sqlx-mysql", "runtime-tokio-rustls", "macros" ] }
time = { workspace = true }

37
entity/src/document.rs Normal file
View file

@ -0,0 +1,37 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "document")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub user: String,
pub device: String,
pub device_id: String,
#[sea_orm(column_type = "Float")]
pub percentage: f32,
pub progress: String,
pub timestamp: TimeDateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::User",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

6
entity/src/lib.rs Normal file
View file

@ -0,0 +1,6 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
pub mod prelude;
pub mod document;
pub mod user;

4
entity/src/prelude.rs Normal file
View file

@ -0,0 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
pub use super::document::Entity as Document;
pub use super::user::Entity as User;

25
entity/src/user.rs Normal file
View file

@ -0,0 +1,25 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub key: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::document::Entity")]
Document,
}
impl Related<super::document::Entity> for Entity {
fn to() -> RelationDef {
Relation::Document.def()
}
}
impl ActiveModelBehavior for ActiveModel {}