add downloads
This commit is contained in:
parent
cbaea15f4f
commit
a63c4febf4
5 changed files with 77 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ pub mod update {
|
||||||
pub slug: Patch<game::Slug>,
|
pub slug: Patch<game::Slug>,
|
||||||
pub thumbnail: Patch<Option<file::Id>>,
|
pub thumbnail: Patch<Option<file::Id>>,
|
||||||
pub genres: Patch<mark::Genres>,
|
pub genres: Patch<mark::Genres>,
|
||||||
|
pub downloads: Patch<Vec<game::Download>>,
|
||||||
pub badges: Patch<mark::Badges>,
|
pub badges: Patch<mark::Badges>,
|
||||||
pub tags: Patch<mark::Tags>,
|
pub tags: Patch<mark::Tags>,
|
||||||
pub screenshots: Patch<game::Screenshots>,
|
pub screenshots: Patch<game::Screenshots>,
|
||||||
|
|
@ -153,6 +154,8 @@ pub mod create {
|
||||||
pub tags: mark::Tags,
|
pub tags: mark::Tags,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub genres: mark::Genres,
|
pub genres: mark::Genres,
|
||||||
|
#[serde(default)]
|
||||||
|
pub downloads: Vec<game::Download>,
|
||||||
pub slug: Option<game::Slug>,
|
pub slug: Option<game::Slug>,
|
||||||
pub vndb: Option<game::VndbId>,
|
pub vndb: Option<game::VndbId>,
|
||||||
pub release_date: Option<game::ReleaseDate>,
|
pub release_date: Option<game::ReleaseDate>,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use eva::{array, data, int, str, str::CompactString, time::Date};
|
use eva::{array, data, int, str, str::CompactString, time::Date, url};
|
||||||
|
|
||||||
use crate::types::{author, entity::define_eid, file, mark, slug, user};
|
use crate::types::{author, entity::define_eid, file, mark, slug, user};
|
||||||
|
|
||||||
|
|
@ -80,6 +80,30 @@ pub struct Marks {
|
||||||
pub badges: HashMap<mark::Badge, CompactString>,
|
pub badges: HashMap<mark::Badge, CompactString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[data(copy)]
|
||||||
|
pub enum Platform {
|
||||||
|
Android,
|
||||||
|
Ios,
|
||||||
|
Pc {
|
||||||
|
linux: bool,
|
||||||
|
mac: bool,
|
||||||
|
windows: bool,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
pub enum DownloadLink {
|
||||||
|
External(url::Url),
|
||||||
|
Dedicated(file::Id),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
pub struct Download {
|
||||||
|
pub platform: Platform,
|
||||||
|
pub link: DownloadLink,
|
||||||
|
pub label: CompactString,
|
||||||
|
}
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
pub struct Game {
|
pub struct Game {
|
||||||
pub id: Id,
|
pub id: Id,
|
||||||
|
|
@ -95,6 +119,7 @@ pub struct Game {
|
||||||
pub author: author::Mini,
|
pub author: author::Mini,
|
||||||
pub release_date: Option<ReleaseDate>,
|
pub release_date: Option<ReleaseDate>,
|
||||||
pub publication: Option<Publication>,
|
pub publication: Option<Publication>,
|
||||||
|
pub downloads: Vec<Download>,
|
||||||
|
|
||||||
pub screenshots: Screenshots,
|
pub screenshots: Screenshots,
|
||||||
pub tags: mark::Tags,
|
pub tags: mark::Tags,
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ impl Games for HttpClient {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
downloads,
|
||||||
author,
|
author,
|
||||||
slug,
|
slug,
|
||||||
vndb,
|
vndb,
|
||||||
|
|
@ -77,6 +78,7 @@ impl Games for HttpClient {
|
||||||
thumbnail,
|
thumbnail,
|
||||||
author,
|
author,
|
||||||
tags,
|
tags,
|
||||||
|
downloads,
|
||||||
genres,
|
genres,
|
||||||
slug,
|
slug,
|
||||||
vndb,
|
vndb,
|
||||||
|
|
@ -92,6 +94,7 @@ impl Games for HttpClient {
|
||||||
(
|
(
|
||||||
c!("/games/{id}"),
|
c!("/games/{id}"),
|
||||||
requests::Update {
|
requests::Update {
|
||||||
|
downloads: update.downloads,
|
||||||
title: update.title,
|
title: update.title,
|
||||||
description: update.description,
|
description: update.description,
|
||||||
slug: update.slug,
|
slug: update.slug,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ pub struct Update {
|
||||||
pub description: Patch<Option<game::Description>>,
|
pub description: Patch<Option<game::Description>>,
|
||||||
pub slug: Patch<game::Slug>,
|
pub slug: Patch<game::Slug>,
|
||||||
pub thumbnail: Patch<Option<file::Id>>,
|
pub thumbnail: Patch<Option<file::Id>>,
|
||||||
|
pub downloads: Patch<Vec<game::Download>>,
|
||||||
pub genres: Patch<mark::Genres>,
|
pub genres: Patch<mark::Genres>,
|
||||||
pub badges: Patch<mark::Badges>,
|
pub badges: Patch<mark::Badges>,
|
||||||
pub tags: Patch<mark::Tags>,
|
pub tags: Patch<mark::Tags>,
|
||||||
|
|
@ -71,6 +72,8 @@ pub struct Create {
|
||||||
pub description: Option<game::Description>,
|
pub description: Option<game::Description>,
|
||||||
pub thumbnail: Option<file::Id>,
|
pub thumbnail: Option<file::Id>,
|
||||||
pub author: author::Id,
|
pub author: author::Id,
|
||||||
|
#[serde(default)]
|
||||||
|
pub downloads: Vec<game::Download>,
|
||||||
pub slug: Option<game::Slug>,
|
pub slug: Option<game::Slug>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub tags: mark::Tags,
|
pub tags: mark::Tags,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use crate::requests::games::{Create, Get, Search};
|
use crate::requests::games::{Create, Get, Search, Update};
|
||||||
|
|
||||||
use viendesu_core::{
|
use viendesu_core::{
|
||||||
requests::games::{create, get, search},
|
requests::games::{create, get, search, update},
|
||||||
service::games::Games,
|
service::games::Games,
|
||||||
types::{author, game},
|
types::{author, game},
|
||||||
};
|
};
|
||||||
|
|
@ -21,6 +21,7 @@ pub fn make<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
||||||
genres,
|
genres,
|
||||||
author,
|
author,
|
||||||
slug,
|
slug,
|
||||||
|
downloads,
|
||||||
vndb,
|
vndb,
|
||||||
release_date,
|
release_date,
|
||||||
} = ctx.request;
|
} = ctx.request;
|
||||||
|
|
@ -31,6 +32,7 @@ pub fn make<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
downloads,
|
||||||
author,
|
author,
|
||||||
slug,
|
slug,
|
||||||
tags,
|
tags,
|
||||||
|
|
@ -41,6 +43,44 @@ pub fn make<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
||||||
.await
|
.await
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
.route(
|
||||||
|
"/{game_id}",
|
||||||
|
patch(async |mut session: SessionOf<T>, mut ctx: Ctx<Update>| {
|
||||||
|
let game_id: game::Id = ctx.path().await?;
|
||||||
|
let Update {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
slug,
|
||||||
|
thumbnail,
|
||||||
|
downloads,
|
||||||
|
genres,
|
||||||
|
badges,
|
||||||
|
tags,
|
||||||
|
screenshots,
|
||||||
|
published,
|
||||||
|
} = ctx.request;
|
||||||
|
|
||||||
|
session
|
||||||
|
.games()
|
||||||
|
.update()
|
||||||
|
.call(update::Args {
|
||||||
|
id: game_id,
|
||||||
|
update: update::Update {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
slug,
|
||||||
|
thumbnail,
|
||||||
|
genres,
|
||||||
|
downloads,
|
||||||
|
badges,
|
||||||
|
tags,
|
||||||
|
screenshots,
|
||||||
|
published,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}),
|
||||||
|
)
|
||||||
.route(
|
.route(
|
||||||
"/{game_id}",
|
"/{game_id}",
|
||||||
get(async |mut session: SessionOf<T>, mut ctx: Ctx<Get>| {
|
get(async |mut session: SessionOf<T>, mut ctx: Ctx<Get>| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue