chore: 变更模型定义(仍非最终)

This commit is contained in:
amtoaer
2024-03-27 00:37:25 +08:00
parent 0320d30ab2
commit 748d0a7830
4 changed files with 22 additions and 55 deletions
-1
View File
@@ -13,7 +13,6 @@ pub struct Model {
pub path: String, pub path: String,
pub enabled: bool, pub enabled: bool,
pub created_at: String, pub created_at: String,
pub updated_at: String,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+1 -3
View File
@@ -9,15 +9,13 @@ pub struct Model {
pub id: i32, pub id: i32,
pub video_id: i32, pub video_id: i32,
pub cid: i32, pub cid: i32,
pub page: i32, pub pid: i32,
pub name: String, pub name: String,
pub path: String, pub path: String,
pub image: String, pub image: String,
pub valid: bool, pub valid: bool,
pub download_status: i32, pub download_status: i32,
pub downloaded: bool,
pub created_at: String, pub created_at: String,
pub updated_at: String,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+8 -8
View File
@@ -9,21 +9,21 @@ pub struct Model {
pub id: i32, pub id: i32,
pub favorite_id: i32, pub favorite_id: i32,
pub upper_id: i32, pub upper_id: i32,
pub upper_name: String,
pub name: String, pub name: String,
pub path: String, pub path: String,
pub category: String, pub category: i32,
pub bvid: String, pub bvid: String,
pub intro: String, pub intro: String,
pub cover: String, pub cover: String,
pub ctime: String, pub ctime: DateTime,
pub pubtime: String, pub pubtime: DateTime,
pub favtime: String, pub favtime: DateTime,
pub downloaded: bool, pub handled: bool,
pub valid: bool, pub valid: bool,
pub tags: String, pub tags: Option<String>,
pub single_page: bool, pub single_page: Option<bool>,
pub created_at: String, pub created_at: String,
pub updated_at: String,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+13 -43
View File
@@ -1,5 +1,4 @@
use sea_orm_migration::prelude::*; use sea_orm_migration::prelude::*;
use sea_orm_migration::sea_orm::{EnumIter, Iterable};
#[derive(DeriveMigrationName)] #[derive(DeriveMigrationName)]
pub struct Migration; pub struct Migration;
@@ -34,12 +33,6 @@ impl MigrationTrait for Migration {
.default(Expr::current_timestamp()) .default(Expr::current_timestamp())
.not_null(), .not_null(),
) )
.col(
ColumnDef::new(Favorite::UpdatedAt)
.timestamp()
.default(Expr::current_timestamp())
.not_null(),
)
.to_owned(), .to_owned(),
) )
.await?; .await?;
@@ -57,31 +50,27 @@ impl MigrationTrait for Migration {
) )
.col(ColumnDef::new(Video::FavoriteId).unsigned().not_null()) .col(ColumnDef::new(Video::FavoriteId).unsigned().not_null())
.col(ColumnDef::new(Video::UpperId).unsigned().not_null()) .col(ColumnDef::new(Video::UpperId).unsigned().not_null())
.col(ColumnDef::new(Video::UpperName).string().not_null())
.col(ColumnDef::new(Video::Name).string().not_null()) .col(ColumnDef::new(Video::Name).string().not_null())
.col(ColumnDef::new(Video::Path).string().not_null()) .col(ColumnDef::new(Video::Path).string().not_null())
.col( .col(ColumnDef::new(Video::Category).small_unsigned().not_null())
ColumnDef::new(Video::Category)
.enumeration(Alias::new("category"), Category::iter())
.not_null(),
)
.col(ColumnDef::new(Video::Bvid).string().not_null()) .col(ColumnDef::new(Video::Bvid).string().not_null())
.col(ColumnDef::new(Video::Intro).string().not_null()) .col(ColumnDef::new(Video::Intro).string().not_null())
.col(ColumnDef::new(Video::Cover).string().not_null()) .col(ColumnDef::new(Video::Cover).string().not_null())
.col(ColumnDef::new(Video::Ctime).timestamp().not_null()) .col(ColumnDef::new(Video::Ctime).timestamp().not_null())
.col(ColumnDef::new(Video::Pubtime).timestamp().not_null()) .col(ColumnDef::new(Video::Pubtime).timestamp().not_null())
.col(ColumnDef::new(Video::Favtime).timestamp().not_null()) .col(ColumnDef::new(Video::Favtime).timestamp().not_null())
.col(ColumnDef::new(Video::Downloaded).boolean().not_null())
.col(ColumnDef::new(Video::Valid).boolean().not_null())
.col(ColumnDef::new(Video::Tags).json_binary().not_null())
.col(ColumnDef::new(Video::SinglePage).boolean().not_null())
.col( .col(
ColumnDef::new(Video::CreatedAt) ColumnDef::new(Video::Handled)
.timestamp() .boolean()
.default(Expr::current_timestamp()) .default(false)
.not_null(), .not_null(),
) )
.col(ColumnDef::new(Video::Valid).boolean().not_null())
.col(ColumnDef::new(Video::Tags).json_binary())
.col(ColumnDef::new(Video::SinglePage).boolean())
.col( .col(
ColumnDef::new(Video::UpdatedAt) ColumnDef::new(Video::CreatedAt)
.timestamp() .timestamp()
.default(Expr::current_timestamp()) .default(Expr::current_timestamp())
.not_null(), .not_null(),
@@ -109,19 +98,12 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Page::Image).string().not_null()) .col(ColumnDef::new(Page::Image).string().not_null())
.col(ColumnDef::new(Page::Valid).boolean().not_null()) .col(ColumnDef::new(Page::Valid).boolean().not_null())
.col(ColumnDef::new(Page::DownloadStatus).unsigned().not_null()) .col(ColumnDef::new(Page::DownloadStatus).unsigned().not_null())
.col(ColumnDef::new(Page::Downloaded).boolean().not_null())
.col( .col(
ColumnDef::new(Page::CreatedAt) ColumnDef::new(Page::CreatedAt)
.timestamp() .timestamp()
.default(Expr::current_timestamp()) .default(Expr::current_timestamp())
.not_null(), .not_null(),
) )
.col(
ColumnDef::new(Page::UpdatedAt)
.timestamp()
.default(Expr::current_timestamp())
.not_null(),
)
.to_owned(), .to_owned(),
) )
.await?; .await?;
@@ -132,6 +114,7 @@ impl MigrationTrait for Migration {
.name("idx_video_favorite_id_bvid") .name("idx_video_favorite_id_bvid")
.col(Video::FavoriteId) .col(Video::FavoriteId)
.col(Video::Bvid) .col(Video::Bvid)
.unique()
.to_owned(), .to_owned(),
) )
.await?; .await?;
@@ -142,6 +125,7 @@ impl MigrationTrait for Migration {
.name("idx_page_video_id_pid") .name("idx_page_video_id_pid")
.col(Page::VideoId) .col(Page::VideoId)
.col(Page::Pid) .col(Page::Pid)
.unique()
.to_owned(), .to_owned(),
) )
.await?; .await?;
@@ -171,7 +155,6 @@ enum Favorite {
Path, Path,
Enabled, Enabled,
CreatedAt, CreatedAt,
UpdatedAt,
} }
#[derive(DeriveIden)] #[derive(DeriveIden)]
@@ -180,6 +163,7 @@ enum Video {
Id, Id,
FavoriteId, FavoriteId,
UpperId, UpperId,
UpperName,
Name, Name,
Path, Path,
Category, Category,
@@ -189,12 +173,11 @@ enum Video {
Ctime, Ctime,
Pubtime, Pubtime,
Favtime, Favtime,
Downloaded, Handled,
Valid, Valid,
Tags, Tags,
SinglePage, SinglePage,
CreatedAt, CreatedAt,
UpdatedAt,
} }
#[derive(DeriveIden)] #[derive(DeriveIden)]
@@ -209,18 +192,5 @@ enum Page {
Image, Image,
Valid, Valid,
DownloadStatus, DownloadStatus,
Downloaded,
CreatedAt, CreatedAt,
UpdatedAt,
}
// 参考: https://socialsisteryi.github.io/bilibili-API-collect/docs/fav/list.html#%E8%8E%B7%E5%8F%96%E6%94%B6%E8%97%8F%E5%A4%B9%E5%86%85%E5%AE%B9%E6%98%8E%E7%BB%86%E5%88%97%E8%A1%A8
#[derive(Iden, EnumIter)]
pub enum Category {
#[iden = "2"]
Video,
#[iden = "12"]
Audio,
#[iden = "21"]
VideoCollection,
} }