spit into crates and fix app
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-07-07 15:10:31 +02:00
parent 26e39c7c06
commit 35bde07b39
27 changed files with 751 additions and 384 deletions

View File

@@ -1,4 +1,5 @@
use sea_orm::entity::prelude::*;
use sea_orm::Set;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "devices")]
@@ -36,4 +37,12 @@ impl Related<super::sessions::Entity> for Entity {
}
}
impl ActiveModelBehavior for ActiveModel {}
impl ActiveModelBehavior for ActiveModel {
fn new() -> Self {
Self {
uuid: Set(Uuid::new_v4()),
device_id: Set(Uuid::new_v4().to_string()),
..ActiveModelTrait::default()
}
}
}

View File

@@ -1,3 +1,4 @@
pub mod users;
pub mod devices;
pub mod sessions;
pub mod sessions;
pub mod prelude;

View File

@@ -0,0 +1,6 @@
#[allow(unused_imports)]
pub use crate::{
devices::{self, Entity as Device},
sessions::{self, Entity as Session},
users::{self, Entity as User},
};

View File

@@ -1,4 +1,5 @@
use sea_orm::entity::prelude::*;
use sea_orm::Set;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "users")]
@@ -13,7 +14,7 @@ pub struct Model {
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::devices::Entity")]
Devices
Devices,
}
impl Related<super::devices::Entity> for Entity {
@@ -22,4 +23,11 @@ impl Related<super::devices::Entity> for Entity {
}
}
impl ActiveModelBehavior for ActiveModel {}
impl ActiveModelBehavior for ActiveModel {
fn new() -> Self {
Self {
uuid: Set(Uuid::new_v4()),
..ActiveModelTrait::default()
}
}
}