add downloads

This commit is contained in:
Aleksandr 2026-01-11 21:00:40 +03:00
parent cbaea15f4f
commit a63c4febf4
5 changed files with 77 additions and 3 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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>| {