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 thumbnail: Patch<Option<file::Id>>,
|
||||
pub genres: Patch<mark::Genres>,
|
||||
pub downloads: Patch<Vec<game::Download>>,
|
||||
pub badges: Patch<mark::Badges>,
|
||||
pub tags: Patch<mark::Tags>,
|
||||
pub screenshots: Patch<game::Screenshots>,
|
||||
|
|
@ -153,6 +154,8 @@ pub mod create {
|
|||
pub tags: mark::Tags,
|
||||
#[serde(default)]
|
||||
pub genres: mark::Genres,
|
||||
#[serde(default)]
|
||||
pub downloads: Vec<game::Download>,
|
||||
pub slug: Option<game::Slug>,
|
||||
pub vndb: Option<game::VndbId>,
|
||||
pub release_date: Option<game::ReleaseDate>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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};
|
||||
|
||||
|
|
@ -80,6 +80,30 @@ pub struct Marks {
|
|||
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]
|
||||
pub struct Game {
|
||||
pub id: Id,
|
||||
|
|
@ -95,6 +119,7 @@ pub struct Game {
|
|||
pub author: author::Mini,
|
||||
pub release_date: Option<ReleaseDate>,
|
||||
pub publication: Option<Publication>,
|
||||
pub downloads: Vec<Download>,
|
||||
|
||||
pub screenshots: Screenshots,
|
||||
pub tags: mark::Tags,
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ impl Games for HttpClient {
|
|||
title,
|
||||
description,
|
||||
thumbnail,
|
||||
downloads,
|
||||
author,
|
||||
slug,
|
||||
vndb,
|
||||
|
|
@ -77,6 +78,7 @@ impl Games for HttpClient {
|
|||
thumbnail,
|
||||
author,
|
||||
tags,
|
||||
downloads,
|
||||
genres,
|
||||
slug,
|
||||
vndb,
|
||||
|
|
@ -92,6 +94,7 @@ impl Games for HttpClient {
|
|||
(
|
||||
c!("/games/{id}"),
|
||||
requests::Update {
|
||||
downloads: update.downloads,
|
||||
title: update.title,
|
||||
description: update.description,
|
||||
slug: update.slug,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ pub struct Update {
|
|||
pub description: Patch<Option<game::Description>>,
|
||||
pub slug: Patch<game::Slug>,
|
||||
pub thumbnail: Patch<Option<file::Id>>,
|
||||
pub downloads: Patch<Vec<game::Download>>,
|
||||
pub genres: Patch<mark::Genres>,
|
||||
pub badges: Patch<mark::Badges>,
|
||||
pub tags: Patch<mark::Tags>,
|
||||
|
|
@ -71,6 +72,8 @@ pub struct Create {
|
|||
pub description: Option<game::Description>,
|
||||
pub thumbnail: Option<file::Id>,
|
||||
pub author: author::Id,
|
||||
#[serde(default)]
|
||||
pub downloads: Vec<game::Download>,
|
||||
pub slug: Option<game::Slug>,
|
||||
#[serde(default)]
|
||||
pub tags: mark::Tags,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use super::*;
|
||||
|
||||
use crate::requests::games::{Create, Get, Search};
|
||||
use crate::requests::games::{Create, Get, Search, Update};
|
||||
|
||||
use viendesu_core::{
|
||||
requests::games::{create, get, search},
|
||||
requests::games::{create, get, search, update},
|
||||
service::games::Games,
|
||||
types::{author, game},
|
||||
};
|
||||
|
|
@ -21,6 +21,7 @@ pub fn make<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
|||
genres,
|
||||
author,
|
||||
slug,
|
||||
downloads,
|
||||
vndb,
|
||||
release_date,
|
||||
} = ctx.request;
|
||||
|
|
@ -31,6 +32,7 @@ pub fn make<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
|||
title,
|
||||
description,
|
||||
thumbnail,
|
||||
downloads,
|
||||
author,
|
||||
slug,
|
||||
tags,
|
||||
|
|
@ -41,6 +43,44 @@ pub fn make<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
|||
.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(
|
||||
"/{game_id}",
|
||||
get(async |mut session: SessionOf<T>, mut ctx: Ctx<Get>| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue