Initial commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, EnumIter, DeriveActiveEnum)]
|
||||
#[sea_orm(rs_type = "String", db_type = "Text")]
|
||||
pub enum DownloadStatus {
|
||||
#[sea_orm(string_value = "pending")]
|
||||
Pending,
|
||||
#[sea_orm(string_value = "downloading")]
|
||||
Downloading,
|
||||
#[sea_orm(string_value = "completed")]
|
||||
Completed,
|
||||
#[sea_orm(string_value = "failed")]
|
||||
Failed,
|
||||
#[sea_orm(string_value = "cancelled")]
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "download_queue")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
#[sea_orm(nullable)]
|
||||
pub wanted_item_id: Option<i32>,
|
||||
pub query: String,
|
||||
#[sea_orm(nullable)]
|
||||
pub source_url: Option<String>,
|
||||
pub source_backend: String,
|
||||
pub status: DownloadStatus,
|
||||
#[sea_orm(nullable)]
|
||||
pub error_message: Option<String>,
|
||||
pub retry_count: i32,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
pub updated_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::wanted_item::Entity",
|
||||
from = "Column::WantedItemId",
|
||||
to = "super::wanted_item::Column::Id",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
WantedItem,
|
||||
}
|
||||
|
||||
impl Related<super::wanted_item::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::WantedItem.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user