60 lines
1.6 KiB
Rust
60 lines
1.6 KiB
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "application")]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
#[serde(skip_deserializing)]
|
|
pub id: i32,
|
|
pub app_name: String,
|
|
pub url: String,
|
|
pub description: Option<String>,
|
|
pub active: bool,
|
|
pub glyph: Option<String>,
|
|
pub application_category_id: Option<i32>,
|
|
pub enable_healthcheck: bool,
|
|
pub favicon: bool,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
|
pub enum Relation {
|
|
ApplicationCategory,
|
|
}
|
|
|
|
impl RelationTrait for Relation {
|
|
fn def(&self) -> RelationDef {
|
|
match self {
|
|
Self::ApplicationCategory => Entity::belongs_to(super::application_category::Entity)
|
|
.from(Column::ApplicationCategoryId)
|
|
.to(super::application_category::Column::Id)
|
|
.into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Related<super::application_category::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::ApplicationCategory.def()
|
|
}
|
|
}
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
|
|
#[cfg(test)]
|
|
impl Default for Model {
|
|
fn default() -> Self {
|
|
Self {
|
|
id: Default::default(),
|
|
app_name: Default::default(),
|
|
url: Default::default(),
|
|
description: Default::default(),
|
|
active: true,
|
|
glyph: Default::default(),
|
|
application_category_id: Default::default(),
|
|
enable_healthcheck: false,
|
|
favicon: false,
|
|
}
|
|
}
|
|
}
|