Initial commit
This commit is contained in:
commit
bd9b07052b
81 changed files with 5516 additions and 0 deletions
81
http/src/requests/games.rs
Normal file
81
http/src/requests/games.rs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
use eva::data;
|
||||
|
||||
use crate::requests::status_code;
|
||||
|
||||
use viendesu_core::{
|
||||
errors,
|
||||
requests::games as reqs,
|
||||
types::{Patch, author, file, game},
|
||||
};
|
||||
|
||||
#[data]
|
||||
#[serde_with::apply(Patch => #[serde(default)])]
|
||||
pub struct Update {
|
||||
pub title: Patch<game::Title>,
|
||||
pub description: Patch<Option<game::Description>>,
|
||||
pub slug: Patch<game::Slug>,
|
||||
pub thumbnail: Patch<Option<file::Id>>,
|
||||
pub genres: Patch<game::Genres>,
|
||||
pub badges: Patch<game::Badges>,
|
||||
pub tags: Patch<game::Tags>,
|
||||
pub screenshots: Patch<game::Screenshots>,
|
||||
pub published: Patch<bool>,
|
||||
}
|
||||
|
||||
impl_req!(Update => [reqs::update::Ok; reqs::update::Err]);
|
||||
|
||||
status_code::direct!(reqs::update::Ok => OK);
|
||||
status_code::map!(reqs::update::Err => [NotFound]);
|
||||
|
||||
#[data]
|
||||
pub struct Search {
|
||||
pub query: Option<game::SearchQuery>,
|
||||
pub author: Option<author::Selector>,
|
||||
#[serde(default)]
|
||||
pub include: reqs::search::Condition,
|
||||
#[serde(default)]
|
||||
pub exclude: reqs::search::Condition,
|
||||
#[serde(default)]
|
||||
pub order: reqs::search::Order,
|
||||
#[serde(default)]
|
||||
pub sort_by: reqs::search::SortBy,
|
||||
pub limit: Option<reqs::search::Limit>,
|
||||
}
|
||||
|
||||
impl_req!(Search => [reqs::search::Ok; reqs::search::Err]);
|
||||
|
||||
status_code::direct!(reqs::search::Ok => OK);
|
||||
status_code::map!(reqs::search::Err => [NoSuchAuthor]);
|
||||
|
||||
#[data]
|
||||
pub struct Get {}
|
||||
|
||||
impl_req!(Get => [reqs::get::Ok; reqs::get::Err]);
|
||||
|
||||
status_code::direct!(reqs::get::Ok => OK);
|
||||
status_code::map!(reqs::get::Err => [NotFound, NoSuchAuthor]);
|
||||
|
||||
#[data]
|
||||
pub struct Create {
|
||||
pub title: game::Title,
|
||||
pub description: Option<game::Description>,
|
||||
pub thumbnail: Option<file::Id>,
|
||||
pub author: author::Id,
|
||||
pub slug: Option<game::Slug>,
|
||||
pub vndb: Option<game::VndbId>,
|
||||
pub release_date: Option<game::ReleaseDate>,
|
||||
}
|
||||
|
||||
impl_req!(Create => [reqs::create::Ok; reqs::create::Err]);
|
||||
|
||||
status_code::direct!(reqs::create::Ok => CREATED);
|
||||
status_code::map!(reqs::create::Err => [AlreadyTaken, NoSuchAuthor]);
|
||||
|
||||
const _: () = {
|
||||
use errors::games::*;
|
||||
use status_code::direct;
|
||||
|
||||
direct!(NotFound => NOT_FOUND);
|
||||
direct!(NotAnOwner => FORBIDDEN);
|
||||
direct!(AlreadyTaken => BAD_REQUEST);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue