//! `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 = "menu_commodity")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    #[sea_orm(column_type = "Text", nullable)]
    pub name: Option<String>,
    pub cate_id: Option<i32>,
    #[sea_orm(column_type = "Text", nullable)]
    pub goods_no: Option<String>,
    pub is_single_spec: Option<i32>,
    #[sea_orm(column_type = "Text", nullable)]
    pub logo: Option<String>,
    pub price: Option<Decimal>,
    pub line_price: Option<Decimal>,
    pub stock: Option<i32>,
    pub sort: Option<i32>,
    #[sea_orm(column_type = "Text", nullable)]
    pub description: Option<String>,
    #[sea_orm(column_type = "custom(\"DATETIME\")", nullable)]
    pub create_time: Option<String>,
    #[sea_orm(column_type = "custom(\"DATETIME\")", nullable)]
    pub update_time: Option<String>,
    pub status: Option<i32>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::menu_cate::Entity",
        from = "Column::CateId",
        to = "super::menu_cate::Column::Id",
        on_update = "NoAction",
        on_delete = "NoAction"
    )]
    MenuCate,
    #[sea_orm(has_many = "super::menu_sku::Entity")]
    MenuSku,
    #[sea_orm(has_many = "super::menu_spec::Entity")]
    MenuSpec,
}

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

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

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

impl ActiveModelBehavior for ActiveModel {}
