Game & Group Put + Delete Endpoints

This commit is contained in:
Neshura 2023-09-02 20:23:34 +02:00
parent 8fd4321944
commit eb18526f51
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
3 changed files with 442 additions and 119 deletions

View file

@ -1,20 +1,8 @@
use std::collections::HashMap;
use std::{collections::HashMap};
use serde::{Serialize, Deserialize};
use utoipa::{ToSchema, IntoParams};
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct AuthParamsOptional {
#[schema(example = "1357")]
pub token: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct AuthParams {
#[schema(example = "1357")]
pub token: String,
}
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct AuthReturn {
#[schema(example = false)]
@ -23,14 +11,24 @@ pub struct AuthReturn {
pub admin: bool,
}
// Game Structs
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct GetGameParam {
pub game_id: Option<usize>,
#[schema(example = 0)]
pub game_id: i32,
}
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct PostGameParams {
pub auth: AuthParams,
#[schema(example = "Game XY")]
pub game_name: String,
}
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct UpdateGameParams {
#[schema(example = 0)]
pub game_id: i32,
#[schema(example = "Game XY")]
pub game_name: String,
}
@ -38,44 +36,97 @@ pub struct PostGameParams {
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct DeleteGameParam {
#[schema(example = 0)]
pub game_id: usize,
pub game_id: i32,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct FullViewData {
pub games: HashMap<i32, ChellarisGame>,
pub games: HashMap<i32, ChellarisGameLegacy>,
pub ethics: HashMap<i32, Ethic>,
pub species: HashMap<i32, Species>,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisGameLegacy {
pub id: i32,
pub name: String,
pub groups: HashMap<i32, ChellarisGameGroupLegacy>,
pub empires: HashMap<i32, ChellarisEmpire>,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisGameFlat {
pub id: i32,
pub name: String,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisGame {
pub id: i32,
pub name: String,
pub groups: HashMap<i32, ChellarisGameGroup>,
pub empires: HashMap<i32, ChellarisEmpire>,
pub empires: HashMap<i32, ChellarisEmpireFlat>,
pub groups: HashMap<i32, ChellarisGroupFlat>
}
// Group Structs
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct PostGroupParams {
#[schema(example = "Group XY")]
pub group_name: String,
#[schema(example = 0)]
pub game_id: i32
}
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct UpdateGroupParams {
#[schema(example = 0)]
pub group_id: i32,
#[schema(example = 0)]
pub game_id: i32,
#[schema(example = "Group XY")]
pub group_name: String
}
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct DeleteGroupParams {
#[schema(example = 0)]
pub group_id: i32,
#[schema(example = 0)]
pub game_id: i32,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisGameLite {
pub struct ChellarisGroupFlat {
pub id: i32,
pub name: String,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisGameGroup {
pub struct ChellarisGameGroupLegacy {
pub id: i32,
pub name: String,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisEmpireFlat {
pub id: i32,
pub group: i32,
pub name: String,
pub discord_user: Option<String>,
pub gestalt: bool,
pub empire_portrait: Option<i32>,
pub empire_portrait_group: Option<i32>,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisEmpire {
pub id: i32,
pub gestalt: bool,
pub machine: bool,
pub group: i32,
pub empire_portrait: i32,
pub empire_portrait_group: i32,
pub empire_portrait: Option<i32>,
pub empire_portrait_group: Option<i32>,
pub discord_user: Option<String>,
pub ethics: HashMap<i32, EmpireEthic>,
}