aboutsummaryrefslogtreecommitdiff
path: root/entity/src
diff options
context:
space:
mode:
Diffstat (limited to 'entity/src')
-rw-r--r--entity/src/access_to_queue.rs46
-rw-r--r--entity/src/lib.rs9
-rw-r--r--entity/src/prelude.rs6
-rw-r--r--entity/src/queue_elements.rs50
-rw-r--r--entity/src/queues.rs51
-rw-r--r--entity/src/sea_orm_active_enums.rs16
-rw-r--r--entity/src/users.rs49
7 files changed, 227 insertions, 0 deletions
diff --git a/entity/src/access_to_queue.rs b/entity/src/access_to_queue.rs
new file mode 100644
index 0000000..9de03d5
--- /dev/null
+++ b/entity/src/access_to_queue.rs
@@ -0,0 +1,46 @@
1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
2
3use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6#[sea_orm(table_name = "access_to_queue")]
7pub struct Model {
8 #[sea_orm(primary_key, auto_increment = false)]
9 pub user_id: i64,
10 #[sea_orm(primary_key, auto_increment = false)]
11 pub queue_id: i64,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16 #[sea_orm(
17 belongs_to = "super::queues::Entity",
18 from = "Column::QueueId",
19 to = "super::queues::Column::Id",
20 on_update = "Cascade",
21 on_delete = "Cascade"
22 )]
23 Queues,
24 #[sea_orm(
25 belongs_to = "super::users::Entity",
26 from = "Column::UserId",
27 to = "super::users::Column::Id",
28 on_update = "Cascade",
29 on_delete = "Cascade"
30 )]
31 Users,
32}
33
34impl Related<super::queues::Entity> for Entity {
35 fn to() -> RelationDef {
36 Relation::Queues.def()
37 }
38}
39
40impl Related<super::users::Entity> for Entity {
41 fn to() -> RelationDef {
42 Relation::Users.def()
43 }
44}
45
46impl ActiveModelBehavior for ActiveModel {}
diff --git a/entity/src/lib.rs b/entity/src/lib.rs
new file mode 100644
index 0000000..1ca05d6
--- /dev/null
+++ b/entity/src/lib.rs
@@ -0,0 +1,9 @@
1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
2
3pub mod prelude;
4
5pub mod access_to_queue;
6pub mod queue_elements;
7pub mod queues;
8pub mod sea_orm_active_enums;
9pub mod users;
diff --git a/entity/src/prelude.rs b/entity/src/prelude.rs
new file mode 100644
index 0000000..60f72f9
--- /dev/null
+++ b/entity/src/prelude.rs
@@ -0,0 +1,6 @@
1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
2
3pub use super::access_to_queue::Entity as AccessToQueue;
4pub use super::queue_elements::Entity as QueueElements;
5pub use super::queues::Entity as Queues;
6pub use super::users::Entity as Users;
diff --git a/entity/src/queue_elements.rs b/entity/src/queue_elements.rs
new file mode 100644
index 0000000..7002da1
--- /dev/null
+++ b/entity/src/queue_elements.rs
@@ -0,0 +1,50 @@
1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
2
3use super::sea_orm_active_enums::QueueElementStatusEnum;
4use sea_orm::entity::prelude::*;
5
6#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
7#[sea_orm(table_name = "queue_elements")]
8pub struct Model {
9 #[sea_orm(primary_key)]
10 pub id: i64,
11 pub queue_id: i64,
12 pub user_id: i64,
13 #[sea_orm(unique)]
14 pub position: i64,
15 pub status: QueueElementStatusEnum,
16}
17
18#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
19pub enum Relation {
20 #[sea_orm(
21 belongs_to = "super::queues::Entity",
22 from = "Column::QueueId",
23 to = "super::queues::Column::Id",
24 on_update = "Cascade",
25 on_delete = "Cascade"
26 )]
27 Queues,
28 #[sea_orm(
29 belongs_to = "super::users::Entity",
30 from = "Column::UserId",
31 to = "super::users::Column::Id",
32 on_update = "Cascade",
33 on_delete = "Cascade"
34 )]
35 Users,
36}
37
38impl Related<super::queues::Entity> for Entity {
39 fn to() -> RelationDef {
40 Relation::Queues.def()
41 }
42}
43
44impl Related<super::users::Entity> for Entity {
45 fn to() -> RelationDef {
46 Relation::Users.def()
47 }
48}
49
50impl ActiveModelBehavior for ActiveModel {}
diff --git a/entity/src/queues.rs b/entity/src/queues.rs
new file mode 100644
index 0000000..34b358a
--- /dev/null
+++ b/entity/src/queues.rs
@@ -0,0 +1,51 @@
1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
2
3use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6#[sea_orm(table_name = "queues")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub id: i64,
10 pub owner_id: i64,
11 pub name: String,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16 #[sea_orm(has_many = "super::access_to_queue::Entity")]
17 AccessToQueue,
18 #[sea_orm(has_many = "super::queue_elements::Entity")]
19 QueueElements,
20 #[sea_orm(
21 belongs_to = "super::users::Entity",
22 from = "Column::OwnerId",
23 to = "super::users::Column::Id",
24 on_update = "Cascade",
25 on_delete = "Cascade"
26 )]
27 Users,
28}
29
30impl Related<super::access_to_queue::Entity> for Entity {
31 fn to() -> RelationDef {
32 Relation::AccessToQueue.def()
33 }
34}
35
36impl Related<super::queue_elements::Entity> for Entity {
37 fn to() -> RelationDef {
38 Relation::QueueElements.def()
39 }
40}
41
42impl Related<super::users::Entity> for Entity {
43 fn to() -> RelationDef {
44 super::access_to_queue::Relation::Users.def()
45 }
46 fn via() -> Option<RelationDef> {
47 Some(super::access_to_queue::Relation::Queues.def().rev())
48 }
49}
50
51impl ActiveModelBehavior for ActiveModel {}
diff --git a/entity/src/sea_orm_active_enums.rs b/entity/src/sea_orm_active_enums.rs
new file mode 100644
index 0000000..2252a9f
--- /dev/null
+++ b/entity/src/sea_orm_active_enums.rs
@@ -0,0 +1,16 @@
1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
2
3use sea_orm::entity::prelude::*;
4
5#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
6#[sea_orm(
7 rs_type = "String",
8 db_type = "Enum",
9 enum_name = "queue_element_status_enum"
10)]
11pub enum QueueElementStatusEnum {
12 #[sea_orm(string_value = "passed")]
13 Passed,
14 #[sea_orm(string_value = "waiting")]
15 Waiting,
16}
diff --git a/entity/src/users.rs b/entity/src/users.rs
new file mode 100644
index 0000000..b61d51b
--- /dev/null
+++ b/entity/src/users.rs
@@ -0,0 +1,49 @@
1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
2
3use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6#[sea_orm(table_name = "users")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub id: i64,
10 #[sea_orm(unique)]
11 pub login: String,
12 pub password: String,
13 pub password_issue_date: DateTime,
14 pub first_name: String,
15 pub last_name: String,
16}
17
18#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
19pub enum Relation {
20 #[sea_orm(has_many = "super::access_to_queue::Entity")]
21 AccessToQueue,
22 #[sea_orm(has_many = "super::queue_elements::Entity")]
23 QueueElements,
24 #[sea_orm(has_many = "super::queues::Entity")]
25 Queues,
26}
27
28impl Related<super::access_to_queue::Entity> for Entity {
29 fn to() -> RelationDef {
30 Relation::AccessToQueue.def()
31 }
32}
33
34impl Related<super::queue_elements::Entity> for Entity {
35 fn to() -> RelationDef {
36 Relation::QueueElements.def()
37 }
38}
39
40impl Related<super::queues::Entity> for Entity {
41 fn to() -> RelationDef {
42 super::access_to_queue::Relation::Queues.def()
43 }
44 fn via() -> Option<RelationDef> {
45 Some(super::access_to_queue::Relation::Users.def().rev())
46 }
47}
48
49impl ActiveModelBehavior for ActiveModel {}