Also integrated entities into codebase
This commit is contained in:
37
src/entity/game.rs
Normal file
37
src/entity/game.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
use super::sea_orm_active_enums::GameType;
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "game")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub time: DateTimeWithTimeZone,
|
||||
pub game_type: Option<GameType>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::game_to_team_result::Entity")]
|
||||
GameToTeamResult,
|
||||
}
|
||||
|
||||
impl Related<super::game_to_team_result::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::GameToTeamResult.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::team_result::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::game_to_team_result::Relation::TeamResult.def()
|
||||
}
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::game_to_team_result::Relation::Game.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
47
src/entity/game_to_team_result.rs
Normal file
47
src/entity/game_to_team_result.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "game_to_team_result")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub game_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub team_result_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::game::Entity",
|
||||
from = "Column::GameId",
|
||||
to = "super::game::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
Game,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::team_result::Entity",
|
||||
from = "Column::TeamResultId",
|
||||
to = "super::team_result::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
TeamResult,
|
||||
}
|
||||
|
||||
impl Related<super::game::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Game.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::team_result::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::TeamResult.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
10
src/entity/mod.rs
Normal file
10
src/entity/mod.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod game;
|
||||
pub mod game_to_team_result;
|
||||
pub mod sea_orm_active_enums;
|
||||
pub mod team_result;
|
||||
pub mod team_result_to_user;
|
||||
pub mod user;
|
||||
7
src/entity/prelude.rs
Normal file
7
src/entity/prelude.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
pub use super::game::Entity as Game;
|
||||
pub use super::game_to_team_result::Entity as GameToTeamResult;
|
||||
pub use super::team_result::Entity as TeamResult;
|
||||
pub use super::team_result_to_user::Entity as TeamResultToUser;
|
||||
pub use super::user::Entity as User;
|
||||
15
src/entity/sea_orm_active_enums.rs
Normal file
15
src/entity/sea_orm_active_enums.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
|
||||
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "game_type")]
|
||||
pub enum GameType {
|
||||
#[sea_orm(string_value = "PickleBall")]
|
||||
PickleBall,
|
||||
#[sea_orm(string_value = "Pool")]
|
||||
Pool,
|
||||
#[sea_orm(string_value = "TableTennis")]
|
||||
TableTennis,
|
||||
}
|
||||
53
src/entity/team_result.rs
Normal file
53
src/entity/team_result.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "team_result")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub place: i32,
|
||||
pub score: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::game_to_team_result::Entity")]
|
||||
GameToTeamResult,
|
||||
#[sea_orm(has_many = "super::team_result_to_user::Entity")]
|
||||
TeamResultToUser,
|
||||
}
|
||||
|
||||
impl Related<super::game_to_team_result::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::GameToTeamResult.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::team_result_to_user::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::TeamResultToUser.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::game::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::game_to_team_result::Relation::Game.def()
|
||||
}
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::game_to_team_result::Relation::TeamResult.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::user::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::team_result_to_user::Relation::User.def()
|
||||
}
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::team_result_to_user::Relation::TeamResult.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
47
src/entity/team_result_to_user.rs
Normal file
47
src/entity/team_result_to_user.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "team_result_to_user")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub team_result_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub user_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::team_result::Entity",
|
||||
from = "Column::TeamResultId",
|
||||
to = "super::team_result::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
TeamResult,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::user::Entity",
|
||||
from = "Column::UserId",
|
||||
to = "super::user::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
User,
|
||||
}
|
||||
|
||||
impl Related<super::team_result::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::TeamResult.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::user::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::User.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
42
src/entity/user.rs
Normal file
42
src/entity/user.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "user")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
pub salt: String,
|
||||
pub creation_time: DateTimeWithTimeZone,
|
||||
pub last_active_time: DateTimeWithTimeZone,
|
||||
pub is_admin: bool,
|
||||
pub email: Option<String>,
|
||||
pub avatar: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::team_result_to_user::Entity")]
|
||||
TeamResultToUser,
|
||||
}
|
||||
|
||||
impl Related<super::team_result_to_user::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::TeamResultToUser.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::team_result::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::team_result_to_user::Relation::TeamResult.def()
|
||||
}
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::team_result_to_user::Relation::User.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user