Schema Update & Empire Endpoints

This commit is contained in:
Neshura 2023-09-03 02:20:26 +02:00
parent eb18526f51
commit 26e83a3aed
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
6 changed files with 600 additions and 74 deletions

View file

@ -15,7 +15,7 @@ pub struct AuthReturn {
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct GetGameParam {
#[schema(example = 0)]
#[schema(example = 1)]
pub game_id: i32,
}
@ -27,7 +27,7 @@ pub struct PostGameParams {
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct UpdateGameParams {
#[schema(example = 0)]
#[schema(example = 1)]
pub game_id: i32,
#[schema(example = "Game XY")]
pub game_name: String,
@ -35,7 +35,7 @@ pub struct UpdateGameParams {
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct DeleteGameParam {
#[schema(example = 0)]
#[schema(example = 1)]
pub game_id: i32,
}
@ -51,7 +51,7 @@ pub struct ChellarisGameLegacy {
pub id: i32,
pub name: String,
pub groups: HashMap<i32, ChellarisGameGroupLegacy>,
pub empires: HashMap<i32, ChellarisEmpire>,
pub empires: HashMap<i32, ChellarisEmpireLegacy>,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
@ -74,15 +74,15 @@ pub struct ChellarisGame {
pub struct PostGroupParams {
#[schema(example = "Group XY")]
pub group_name: String,
#[schema(example = 0)]
#[schema(example = 1)]
pub game_id: i32
}
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct UpdateGroupParams {
#[schema(example = 0)]
#[schema(example = 1)]
pub group_id: i32,
#[schema(example = 0)]
#[schema(example = 1)]
pub game_id: i32,
#[schema(example = "Group XY")]
pub group_name: String
@ -90,9 +90,9 @@ pub struct UpdateGroupParams {
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct DeleteGroupParams {
#[schema(example = 0)]
#[schema(example = 1)]
pub group_id: i32,
#[schema(example = 0)]
#[schema(example = 1)]
pub game_id: i32,
}
@ -108,40 +108,124 @@ pub struct ChellarisGameGroupLegacy {
pub name: String,
}
// Empire Structs
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct PostEmpireParams {
#[schema(example = 1)]
pub game_id: i32,
#[schema(example = 1)]
pub group_id: i32,
#[schema(example = "Example Empire")]
pub empire_name: String,
#[schema(example = true)]
pub gestalt: bool,
#[schema(example = 1)]
pub portrait_id: i32,
#[schema(example = 1)]
pub portrait_group_id: i32,
#[schema(example = json!([
{ "ethic_id": 1, "fanatic": false },
{ "ethic_id": 2, "fanatic": true },
{ "ethic_id": 3, "fanatic": false },
]))]
pub ethics: Vec<EmpireEthic>,
#[schema(example = "UsernameExample")]
pub discord_user: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct UpdateEmpireParams {
#[schema(example = 1)]
pub empire_id: i32,
#[schema(example = 1)]
pub game_id: Option<i32>,
#[schema(example = 1)]
pub group_id: Option<i32>,
#[schema(example = "Example Empire")]
pub empire_name: Option<String>,
#[schema(example = true)]
pub gestalt: Option<bool>,
#[schema(example = 1)]
pub portrait_id: Option<i32>,
#[schema(example = 1)]
pub portrait_group_id: Option<i32>,
#[schema(example = json!([
{ "ethic_id": 1, "fanatic": false },
{ "ethic_id": 2, "fanatic": true },
{ "ethic_id": 3, "fanatic": false },
]))]
pub ethics: Option<Vec<EmpireEthic>>,
#[schema(example = "UsernameExample")]
pub discord_user: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema, Debug, IntoParams)]
pub struct DeleteEmpireParams {
#[schema(example = 1)]
pub game_id: i32,
#[schema(example = 1)]
pub group_id: i32,
#[schema(example = 1)]
pub empire_id: i32,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisEmpireFlat {
pub id: i32,
pub group: i32,
pub game: i32,
pub name: String,
pub discord_user: Option<String>,
pub gestalt: bool,
pub empire_portrait: Option<i32>,
pub empire_portrait_group: Option<i32>,
pub portrait_id: i32,
pub portrait_group_id: i32,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisEmpire {
pub id: i32,
pub group: i32,
pub game: i32,
pub name: String,
pub discord_user: Option<String>,
pub gestalt: bool,
pub portrait_id: i32,
pub portrait_group_id: i32,
pub ethics: HashMap<i32, EmpireEthic>,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct ChellarisEmpireLegacy {
pub id: i32,
pub group: i32,
pub gestalt: bool,
pub machine: bool,
pub group: i32,
pub empire_portrait: Option<i32>,
pub empire_portrait_group: Option<i32>,
pub empire_portrait: i32,
pub empire_portrait_group: i32,
pub discord_user: Option<String>,
pub ethics: HashMap<i32, EmpireEthic>,
pub ethics: HashMap<i32, EmpireEthicLegacy>,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct Ethic {
pub id: i32,
pub displayName: String,
pub display: String,
pub machine: bool,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
#[derive(Serialize, Deserialize, ToSchema, Debug, Clone)]
pub struct EmpireEthic {
#[schema(example = "1")]
pub ethic_id: i32,
#[schema(example = "true")]
pub fanatic: bool,
}
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct EmpireEthicLegacy {
pub id: i32,
pub displayName: String,
pub display: String,
pub machine: bool,
pub fanatic: bool,
}
@ -149,7 +233,7 @@ pub struct EmpireEthic {
#[derive(Serialize, ToSchema, Debug, Clone)]
pub struct Species {
pub id: i32,
pub displayName: String,
pub display: String,
pub portraits: HashMap<i32, Portrait>,
}