125 lines
3.1 KiB
Rust
125 lines
3.1 KiB
Rust
//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2
|
|
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
|
|
pub struct Entity;
|
|
|
|
impl EntityName for Entity {
|
|
fn table_name(&self) -> &str {
|
|
"staff"
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
|
|
pub struct Model {
|
|
pub staff_id: String,
|
|
pub first_name: String,
|
|
pub last_name: String,
|
|
pub address_id: i32,
|
|
pub picture: Option<String>,
|
|
pub email: Option<String>,
|
|
pub store_id: i32,
|
|
pub active: String,
|
|
pub username: String,
|
|
pub password: Option<String>,
|
|
pub last_update: DateTime,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
|
pub enum Column {
|
|
StaffId,
|
|
FirstName,
|
|
LastName,
|
|
AddressId,
|
|
Picture,
|
|
Email,
|
|
StoreId,
|
|
Active,
|
|
Username,
|
|
Password,
|
|
LastUpdate,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
|
pub enum PrimaryKey {
|
|
StaffId,
|
|
}
|
|
|
|
impl PrimaryKeyTrait for PrimaryKey {
|
|
type ValueType = String;
|
|
fn auto_increment() -> bool {
|
|
false
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
|
pub enum Relation {
|
|
Address,
|
|
Store,
|
|
Payment,
|
|
Rental,
|
|
}
|
|
|
|
impl ColumnTrait for Column {
|
|
type EntityName = Entity;
|
|
fn def(&self) -> ColumnDef {
|
|
match self {
|
|
Self::StaffId => ColumnType::Custom("BLOB".to_owned()).def(),
|
|
Self::FirstName => ColumnType::String(None).def(),
|
|
Self::LastName => ColumnType::String(None).def(),
|
|
Self::AddressId => ColumnType::Integer.def(),
|
|
Self::Picture => ColumnType::Custom("BLOB".to_owned()).def().null(),
|
|
Self::Email => ColumnType::String(None).def().null(),
|
|
Self::StoreId => ColumnType::Integer.def(),
|
|
Self::Active => ColumnType::Custom("BLOB".to_owned()).def(),
|
|
Self::Username => ColumnType::String(None).def(),
|
|
Self::Password => ColumnType::String(None).def().null(),
|
|
Self::LastUpdate => ColumnType::Timestamp.def(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl RelationTrait for Relation {
|
|
fn def(&self) -> RelationDef {
|
|
match self {
|
|
Self::Address => Entity::belongs_to(super::address::Entity)
|
|
.from(Column::AddressId)
|
|
.to(super::address::Column::AddressId)
|
|
.into(),
|
|
Self::Store => Entity::belongs_to(super::store::Entity)
|
|
.from(Column::StoreId)
|
|
.to(super::store::Column::StoreId)
|
|
.into(),
|
|
Self::Payment => Entity::has_many(super::payment::Entity).into(),
|
|
Self::Rental => Entity::has_many(super::rental::Entity).into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Related<super::address::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Address.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::store::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Store.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::payment::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Payment.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::rental::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Rental.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|