use bili_sync_entity::*; use sea_orm::{DerivePartialModel, FromQueryResult}; use serde::Serialize; use utoipa::ToSchema; use crate::utils::status::{PageStatus, VideoStatus}; #[derive(Serialize, ToSchema)] pub struct VideoSourcesResponse { pub collection: Vec, pub favorite: Vec, pub submission: Vec, pub watch_later: Vec, } #[derive(Serialize, ToSchema)] pub struct VideosResponse { pub videos: Vec, pub total_count: u64, } #[derive(Serialize, ToSchema)] pub struct VideoResponse { pub video: VideoInfo, pub pages: Vec, } #[derive(Serialize, ToSchema)] pub struct ResetVideoResponse { pub resetted: bool, pub video: VideoInfo, pub pages: Vec, } #[derive(Serialize, ToSchema)] pub struct ResetAllVideosResponse { pub resetted: bool, pub resetted_videos_count: usize, pub resetted_pages_count: usize, } #[derive(Serialize, ToSchema)] pub struct UpdateVideoStatusResponse { pub success: bool, pub video: VideoInfo, pub pages: Vec, } #[derive(FromQueryResult, Serialize, ToSchema)] pub struct VideoSource { id: i32, name: String, } #[derive(Serialize, ToSchema, DerivePartialModel, FromQueryResult)] #[sea_orm(entity = "video::Entity")] pub struct VideoInfo { pub id: i32, pub name: String, pub upper_name: String, #[schema(value_type = [u32; 5])] #[serde(serialize_with = "serde_video_download_status")] pub download_status: u32, } #[derive(Serialize, ToSchema, DerivePartialModel, FromQueryResult)] #[sea_orm(entity = "page::Entity")] pub struct PageInfo { pub id: i32, pub video_id: i32, pub pid: i32, pub name: String, #[schema(value_type = [u32; 5])] #[serde(serialize_with = "serde_page_download_status")] pub download_status: u32, } fn serde_video_download_status(status: &u32, serializer: S) -> Result where S: serde::Serializer, { let status: [u32; 5] = VideoStatus::from(*status).into(); status.serialize(serializer) } fn serde_page_download_status(status: &u32, serializer: S) -> Result where S: serde::Serializer, { let status: [u32; 5] = PageStatus::from(*status).into(); status.serialize(serializer) } #[derive(Serialize, ToSchema)] pub struct FavoriteWithSubscriptionStatus { pub title: String, pub media_count: i64, pub fid: i64, pub mid: i64, pub subscribed: bool, } #[derive(Serialize, ToSchema)] pub struct CollectionWithSubscriptionStatus { pub id: i64, pub mid: i64, pub state: i32, pub title: String, pub subscribed: bool, } #[derive(Serialize, ToSchema)] pub struct UpperWithSubscriptionStatus { pub mid: i64, pub uname: String, pub face: String, pub sign: String, pub subscribed: bool, } #[derive(Serialize, ToSchema)] pub struct FavoritesResponse { pub favorites: Vec, } #[derive(Serialize, ToSchema)] pub struct CollectionsResponse { pub collections: Vec, pub total: i64, } #[derive(Serialize, ToSchema)] pub struct UppersResponse { pub uppers: Vec, pub total: i64, }