use sea_orm::entity::prelude::*;
use serde::Serialize;
use crate::data::user::PlayerRole;
#[derive(Serialize, Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "players")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: u32,
pub email: String,
pub display_name: String,
#[serde(skip)]
pub password: Option<String>,
pub role: PlayerRole,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::player_data::Entity")]
Data,
#[sea_orm(has_one = "super::galaxy_at_war::Entity")]
GalaxyAtWar,
}
impl Related<super::player_data::Entity> for Entity {
fn to() -> RelationDef {
Relation::Data.def()
}
}
impl Related<super::galaxy_at_war::Entity> for Entity {
fn to() -> RelationDef {
Relation::GalaxyAtWar.def()
}
}
impl ActiveModelBehavior for ActiveModel {}