use sea_orm::entity::prelude::*;
use super::state::UserState;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "users")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
#[sea_orm(column_type = "Text", unique)]
pub username: String,
#[sea_orm(column_type = "Text")]
pub encrypted_password: String,
pub auth_signature: Option<i64>,
#[sea_orm(column_type = "Text", nullable)]
pub reset_password_token: Option<String>,
pub reset_password_token_expiry: Option<TimeDateTimeWithTimeZone>,
pub current_sign_in_at: Option<TimeDateTimeWithTimeZone>,
pub last_sign_in_at: Option<TimeDateTimeWithTimeZone>,
#[sea_orm(column_type = "Text", nullable)]
pub current_sign_in_ip: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub last_sign_in_ip: Option<String>,
pub created_at: TimeDateTimeWithTimeZone,
pub updated_at: TimeDateTimeWithTimeZone,
pub admin: bool,
pub state: UserState,
pub group_quota: i32,
pub group_count: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::active_tasks::Entity")]
ActiveTasks,
#[sea_orm(has_many = "super::archived_tasks::Entity")]
ArchivedTasks,
#[sea_orm(has_many = "super::groups::Entity")]
Groups,
#[sea_orm(has_many = "super::user_group::Entity")]
UserGroup,
#[sea_orm(has_many = "super::workers::Entity")]
Workers,
}
impl Related<super::active_tasks::Entity> for Entity {
fn to() -> RelationDef {
Relation::ActiveTasks.def()
}
}
impl Related<super::archived_tasks::Entity> for Entity {
fn to() -> RelationDef {
Relation::ArchivedTasks.def()
}
}
impl Related<super::groups::Entity> for Entity {
fn to() -> RelationDef {
Relation::Groups.def()
}
}
impl Related<super::user_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroup.def()
}
}
impl Related<super::workers::Entity> for Entity {
fn to() -> RelationDef {
Relation::Workers.def()
}
}
impl ActiveModelBehavior for ActiveModel {}