1use serde::{Deserialize, Serialize};
9use utoipa::{IntoParams, ToSchema, schema};
10
11#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
16pub struct ApiResp<T> {
17 #[schema(value_type = i32, example = 0)]
21 pub code: i32,
22
23 #[schema(value_type = String, example = "")]
27 pub msg: String,
28
29 pub data: T,
33}
34
35impl<T> ApiResp<T> {
36 pub fn success(data: T) -> Self {
51 Self {
52 code: 0,
53 msg: String::new(),
54 data,
55 }
56 }
57
58 pub fn error(msg: String) -> Self
73 where
74 T: Default,
75 {
76 Self {
77 code: -1,
78 msg,
79 data: T::default(),
80 }
81 }
82}
83
84#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
88pub struct SongData {
89 #[serde(rename = "cid")]
91 #[schema(value_type = String, example = "953953")]
92 pub id: String,
93
94 #[schema(value_type = String, example = "Little Wish")]
96 pub name: String,
97
98 #[serde(rename = "albumCid")]
100 #[schema(value_type = String, example = "3888")]
101 pub album_id: String,
102
103 #[serde(rename = "sourceUrl")]
105 #[schema(value_type = String, example = "https://res01.hycdn.cn/xxx/xxx.wav")]
106 pub source_url: Option<String>,
107
108 #[serde(rename = "lyricUrl")]
110 #[schema(value_type = String, example = "https://web.hycdn.cn/siren/lyric/xxx/xxx.lrc")]
111 pub lyric_url: Option<String>,
112
113 #[serde(rename = "mvUrl")]
115 pub mv_url: Option<String>,
116
117 #[serde(rename = "mvCoverUrl")]
119 pub mv_cover_url: Option<String>,
120
121 pub artists: Vec<String>,
123}
124
125pub type SongResp = ApiResp<SongData>;
127
128#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
132pub struct AllSongsItem {
133 #[serde(rename = "cid")]
135 #[schema(value_type = String, example = "953953")]
136 pub id: String,
137
138 #[schema(value_type = String, example = "Little Wish")]
140 pub name: String,
141
142 #[serde(rename = "albumCid")]
144 #[schema(value_type = String, example = "3888")]
145 pub album_id: String,
146
147 pub artists: Vec<String>,
149}
150
151#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
153pub struct AllSongsData {
154 pub list: Vec<AllSongsItem>,
156
157 #[serde(rename = "autoplay")]
159 #[schema(value_type = String, example = "048794")]
160 pub auto_paly: String,
161}
162
163pub type AllSongsResp = ApiResp<AllSongsData>;
165
166#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
170pub struct AlbumData {
171 #[serde(rename = "cid")]
173 #[schema(value_type = String, example = "3888")]
174 pub id: String,
175
176 #[schema(value_type = String, example = "Little Wish")]
178 pub name: String,
179
180 #[schema(value_type = String, example = "一触即碎的肥皂泡,也要托起小小愿望,飞越风雨,飞向太阳,绽放她的幻彩流光。")]
182 pub intro: String,
183
184 #[schema(value_type = String, example = "arknights")]
186 pub belong: String,
187
188 #[serde(rename = "coverUrl")]
190 #[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
191 pub cover_url: String,
192
193 #[serde(rename = "coverDeUrl")]
195 #[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
196 pub cover_de_url: String,
197
198 #[serde(rename = "artistes")]
200 pub artists: Vec<String>,
201}
202
203pub type AlbumResp = ApiResp<AlbumData>;
205
206#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
210pub struct AlbumDetailSongItem {
211 #[serde(rename = "cid")]
213 #[schema(value_type = String, example = "953953")]
214 pub id: String,
215
216 #[schema(value_type = String, example = "Little Wish")]
218 pub name: String,
219
220 #[serde(rename = "artistes")]
222 pub artists: Vec<String>,
223}
224
225#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
229pub struct AlbumDetailData {
230 #[serde(rename = "cid")]
232 #[schema(value_type = String, example = "953953")]
233 pub id: String,
234
235 #[schema(value_type = String, example = "Little Wish")]
237 pub name: String,
238
239 #[schema(value_type = String, example = "一触即碎的肥皂泡,也要托起小小愿望,飞越风雨,飞向太阳,绽放她的幻彩流光。")]
241 pub intro: String,
242
243 #[schema(value_type = String, example = "arknights")]
245 pub belong: String,
246
247 #[serde(rename = "coverUrl")]
249 #[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
250 pub cover_url: String,
251
252 #[serde(rename = "coverDeUrl")]
254 #[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
255 pub cover_de_url: String,
256
257 pub songs: Vec<AlbumDetailSongItem>,
259}
260
261pub type AlbumDetailResp = ApiResp<AlbumDetailData>;
263
264#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
268pub struct AllAlbumsItem {
269 #[serde(rename = "cid")]
271 #[schema(value_type = String, example = "3888")]
272 pub id: String,
273
274 #[schema(value_type = String, example = "Little Wish")]
276 pub name: String,
277
278 #[serde(rename = "coverUrl")]
280 #[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
281 pub cover_url: String,
282
283 #[serde(rename = "artistes")]
285 pub artists: Vec<String>,
286}
287
288#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
292pub struct SearchAlbumItem {
293 #[serde(rename = "cid")]
295 #[schema(value_type = String, example = "3888")]
296 pub id: String,
297
298 #[schema(value_type = String, example = "Little Wish")]
300 pub name: String,
301
302 #[schema(value_type = String, example = "arknights")]
304 pub belong: String,
305
306 #[serde(rename = "coverUrl")]
308 #[schema(value_type = String, example = "https://web.hycdn.cn/siren/pic/xxx/xxx.jpg")]
309 pub cover_url: String,
310
311 #[serde(rename = "artistes")]
313 pub artists: Vec<String>,
314}
315
316#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
318pub struct SearchAlbumData {
319 pub list: Vec<SearchAlbumItem>,
321
322 pub end: bool,
324}
325
326#[derive(Serialize, Deserialize, Debug, IntoParams)]
328pub struct SearchAlbumQuery {
329 pub keyword: String,
331
332 #[serde(rename = "lastCid")]
334 pub last_cid: Option<String>,
335}
336
337pub type SearchAlbumResp = ApiResp<SearchAlbumData>;
339
340#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
344pub struct NewsItem {
345 #[serde(rename = "cid")]
347 pub id: String,
348
349 pub title: String,
351
352 pub cate: i32,
354
355 #[schema(value_type = String, example = "2022-01-01")]
357 pub date: String,
358}
359
360#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
362pub struct NewsData {
363 pub list: Vec<NewsItem>,
365
366 pub end: bool,
368}
369
370#[derive(Serialize, Deserialize, Debug, IntoParams)]
372pub struct NewsQuery {
373 pub keyword: String,
375
376 #[serde(rename = "lastCid")]
378 pub last_cid: Option<String>,
379}
380
381#[derive(Serialize, Deserialize, Debug, IntoParams)]
383pub struct AllNewsQuery {
384 #[serde(rename = "lastCid")]
386 pub last_cid: Option<String>,
387}
388
389pub type SearchNewsResp = ApiResp<NewsData>;
391
392#[derive(Serialize, Deserialize, Debug, IntoParams)]
394pub struct SearchQuery {
395 pub keyword: String,
397}
398
399#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
403pub struct SearchData {
404 pub albums: SearchAlbumData,
406
407 pub news: NewsData,
409}
410
411pub type SearchResp = ApiResp<SearchData>;
413
414#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
418pub struct NewsDetailData {
419 #[serde(rename = "cid")]
421 pub id: String,
422
423 pub title: String,
425
426 pub cate: i32,
428
429 pub author: String,
431
432 pub content: String,
434
435 pub date: String,
437}
438
439pub type NewsDetailResp = ApiResp<NewsDetailData>;
441
442#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
446pub struct FontItem {
447 pub tt: String,
449
450 pub eot: String,
452
453 pub svg: String,
455
456 pub woff: String,
458}
459
460#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)]
464pub struct FontData {
465 #[serde(rename = "Sans-Regular")]
467 pub sans_regular: FontItem,
468
469 #[serde(rename = "Sans-Bold")]
471 pub sans_bold: FontItem,
472}
473
474pub type FontResp = ApiResp<FontData>;