use serde::{Deserialize, Serialize};
use utoipa::{schema,IntoParams, ToSchema};
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct ApiResp<T> {
#[schema(value_type = i32, example = 0)]
pub code: i32,
#[schema(value_type = String, example = "")]
pub msg: String,
pub data: T,
}
impl<T> ApiResp<T> {
pub fn success(data: T) -> Self {
Self {
code: 0,
msg: String::new(),
data,
}
}
pub fn error(msg: String) -> Self
where
T: Default,
{
Self {
code: -1,
msg,
data: T::default(),
}
}
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct SongData {
#[serde(rename = "cid")]
#[schema(value_type = String, example = "953953")]
pub id: String,
#[schema(value_type = String, example = "Little Wish")]
pub name: String,
#[serde(rename = "albumCid")]
#[schema(value_type = String, example = "3888")]
pub album_id: String,
#[serde(rename = "sourceUrl")]
#[schema(value_type = String, example = "https://res01.hycdn.cn/xxx/xxx.wav")]
pub source_url: Option<String>,
#[serde(rename = "lyricUrl")]
#[schema(value_type = String, example = "https://web.hycdn.cn/siren/lyric/xxx/xxx.lrc")]
pub lyric_url: Option<String>,
#[serde(rename = "mvUrl")]
pub mv_url: Option<String>,
#[serde(rename = "mvCoverUrl")]
pub mv_cover_url: Option<String>,
pub artists: Vec<String>,
}
pub type SongResp = ApiResp<SongData>;
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct AllSongsItem {
#[serde(rename = "cid")]
#[schema(value_type = String, example = "953953")]
pub id: String,
#[schema(value_type = String, example = "Little Wish")]
pub name: String,
#[serde(rename = "albumCid")]
#[schema(value_type = String, example = "3888")]
pub album_id: String,
pub artists: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct AllSongsData {
pub list: Vec<AllSongsItem>,
#[serde(rename = "autoplay")]
#[schema(value_type = String, example = "048794")]
pub auto_paly: String,
}
pub type AllSongsResp = ApiResp<AllSongsData>;
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct AlbumData {
#[serde(rename = "cid")]
#[schema(value_type = String, example = "3888")]
pub id: String,
#[schema(value_type = String, example = "Little Wish")]
pub name: String,
#[schema(value_type = String, example = "一触即碎的肥皂泡,也要托起小小愿望,飞越风雨,飞向太阳,绽放她的幻彩流光。")]
pub intro: String,
#[schema(value_type = String, example = "arknights")]
pub belong: String,
#[serde(rename = "coverUrl")]
#[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
pub cover_url: String,
#[serde(rename = "coverDeUrl")]
#[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
pub cover_de_url: String,
#[serde(rename = "artistes")]
pub artists: Vec<String>,
}
pub type AlbumResp = ApiResp<AlbumData>;
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct AlbumDetailSongItem {
#[serde(rename = "cid")]
#[schema(value_type = String, example = "953953")]
pub id: String,
#[schema(value_type = String, example = "Little Wish")]
pub name: String,
#[serde(rename = "artistes")]
pub artists: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct AlbumDetailData {
#[serde(rename = "cid")]
#[schema(value_type = String, example = "953953")]
pub id: String,
#[schema(value_type = String, example = "Little Wish")]
pub name: String,
#[schema(value_type = String, example = "一触即碎的肥皂泡,也要托起小小愿望,飞越风雨,飞向太阳,绽放她的幻彩流光。")]
pub intro: String,
#[schema(value_type = String, example = "arknights")]
pub belong: String,
#[serde(rename = "coverUrl")]
#[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
pub cover_url: String,
#[serde(rename = "coverDeUrl")]
#[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
pub cover_de_url: String,
pub songs: Vec<AlbumDetailSongItem>,
}
pub type AlbumDetailResp = ApiResp<AlbumDetailData>;
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct AllAlbumsItem {
#[serde(rename = "cid")]
#[schema(value_type = String, example = "3888")]
pub id: String,
#[schema(value_type = String, example = "Little Wish")]
pub name: String,
#[serde(rename = "coverUrl")]
#[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
pub cover_url: String,
#[serde(rename = "artistes")]
pub artists: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct SearchAlbumItem {
#[serde(rename = "cid")]
#[schema(value_type = String, example = "3888")]
pub id: String,
#[schema(value_type = String, example = "Little Wish")]
pub name: String,
#[schema(value_type = String, example = "arknights")]
pub belong: String,
#[serde(rename = "coverUrl")]
#[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
pub cover_url: String,
#[serde(rename = "artistes")]
pub artists: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct SearchAlbumData {
pub list: Vec<SearchAlbumItem>,
pub end: bool,
}
#[derive(Serialize, Deserialize, Debug, IntoParams)]
pub struct SearchAlbumQuery {
pub keyword: String,
#[serde(rename = "lastCid")]
pub last_cid: Option<String>,
}
pub type SearchAlbumResp = ApiResp<SearchAlbumData>;
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct NewsItem {
#[serde(rename = "cid")]
pub id: String,
pub title: String,
pub cate: i32,
#[schema(value_type = String, example = "2022-01-01")]
pub date: String,
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct NewsData {
pub list: Vec<NewsItem>,
pub end: bool,
}
#[derive(Serialize, Deserialize, Debug, IntoParams)]
pub struct NewsQuery {
pub keyword: String,
#[serde(rename = "lastCid")]
pub last_cid: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, IntoParams)]
pub struct AllNewsQuery {
#[serde(rename = "lastCid")]
pub last_cid: Option<String>,
}
pub type SearchNewsResp = ApiResp<NewsData>;
#[derive(Serialize, Deserialize, Debug, IntoParams)]
pub struct SearchQuery {
pub keyword: String,
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct SearchData {
pub albums: SearchAlbumData,
pub news: NewsData,
}
pub type SearchResp = ApiResp<SearchData>;
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct NewsDetailData {
#[serde(rename = "cid")]
pub id: String,
pub title: String,
pub cate: i32,
pub author: String,
pub content: String,
pub date: String,
}
pub type NewsDetailResp = ApiResp<NewsDetailData>;
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct FontItem {
pub tt: String,
pub eot: String,
pub svg: String,
pub woff: String,
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub struct FontData {
#[serde(rename = "Sans-Regular")]
pub sans_regular: FontItem,
#[serde(rename = "Sans-Bold")]
pub sans_bold: FontItem,
}
pub type FontResp = ApiResp<FontData>;