//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "shared_nodes")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub name: String,
    pub host: String,
    pub port: i32,
    pub protocol: String,
    pub version: String,
    pub allow_relay: bool,
    pub network_name: String,
    pub network_secret: String,
    #[sea_orm(column_type = "Text")]
    pub description: String,
    pub max_connections: i32,
    pub current_connections: i32,
    pub is_active: bool,
    pub is_approved: bool,
    pub qq_number: String,
    pub wechat: String,
    pub mail: String,
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::health_records::Entity")]
    HealthRecords,
    // add relation to node_tags
    #[sea_orm(has_many = "super::node_tags::Entity")]
    NodeTags,
}

impl Related<super::health_records::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::HealthRecords.def()
    }
}

impl Related<super::node_tags::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::NodeTags.def()
    }
}

impl ActiveModelBehavior for ActiveModel {}
