53 lines
1.4 KiB
Rust
53 lines
1.4 KiB
Rust
use sea_orm::{entity::prelude::*, FromJsonQueryResult};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, FromJsonQueryResult)]
|
|
pub struct BangumiFilter {
|
|
pub name: Option<Vec<String>>,
|
|
pub group: Option<Vec<String>>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "bangumi")]
|
|
pub struct Model {
|
|
pub created_at: DateTime,
|
|
pub updated_at: DateTime,
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
pub subscription_id: i32,
|
|
pub display_name: String,
|
|
pub official_title: String,
|
|
pub season: i32,
|
|
pub season_raw: Option<String>,
|
|
pub fansub: Option<String>,
|
|
pub filter: Option<BangumiFilter>,
|
|
pub rss_link: Option<String>,
|
|
pub poster_link: Option<String>,
|
|
pub save_path: Option<String>,
|
|
pub deleted: bool,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::subscriptions::Entity",
|
|
from = "Column::SubscriptionId",
|
|
to = "super::subscriptions::Column::Id"
|
|
)]
|
|
Subscription,
|
|
#[sea_orm(has_many = "super::episodes::Entity")]
|
|
Episode,
|
|
}
|
|
|
|
impl Related<super::episodes::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Episode.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::subscriptions::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Subscription.def()
|
|
}
|
|
}
|