2023-09-02 20:23:34 +02:00
use std ::{ collections ::HashMap } ;
2023-08-26 06:36:12 +02:00
use serde ::{ Serialize , Deserialize } ;
use utoipa ::{ ToSchema , IntoParams } ;
2023-08-30 04:16:43 +02:00
#[ derive(Serialize, Deserialize, ToSchema, Debug) ]
pub struct AuthReturn {
#[ schema(example = false) ]
pub moderator : bool ,
#[ schema(example = false) ]
pub admin : bool ,
}
2023-09-02 20:23:34 +02:00
// Game Structs
2023-08-30 04:16:43 +02:00
#[ derive(Serialize, Deserialize, ToSchema, Debug, IntoParams) ]
pub struct GetGameParam {
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub game_id : i32 ,
2023-08-30 04:16:43 +02:00
}
#[ derive(Serialize, Deserialize, ToSchema, Debug) ]
pub struct PostGameParams {
2023-09-02 20:23:34 +02:00
#[ schema(example = " Game XY " ) ]
pub game_name : String ,
}
#[ derive(Serialize, Deserialize, ToSchema, Debug) ]
pub struct UpdateGameParams {
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub game_id : i32 ,
2023-08-30 04:16:43 +02:00
#[ schema(example = " Game XY " ) ]
pub game_name : String ,
}
#[ derive(Serialize, Deserialize, ToSchema, Debug, IntoParams) ]
pub struct DeleteGameParam {
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub game_id : i32 ,
2023-08-30 04:16:43 +02:00
}
2023-08-26 06:36:12 +02:00
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct FullViewData {
2023-09-02 20:23:34 +02:00
pub games : HashMap < i32 , ChellarisGameLegacy > ,
2023-08-26 06:36:12 +02:00
pub ethics : HashMap < i32 , Ethic > ,
pub species : HashMap < i32 , Species > ,
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
2023-09-02 20:23:34 +02:00
pub struct ChellarisGameLegacy {
2023-08-26 06:36:12 +02:00
pub id : i32 ,
pub name : String ,
2023-09-02 20:23:34 +02:00
pub groups : HashMap < i32 , ChellarisGameGroupLegacy > ,
2023-09-03 02:20:26 +02:00
pub empires : HashMap < i32 , ChellarisEmpireLegacy > ,
2023-08-26 06:36:12 +02:00
}
2023-08-30 04:16:43 +02:00
#[ derive(Serialize, ToSchema, Debug, Clone) ]
2023-09-02 20:23:34 +02:00
pub struct ChellarisGameFlat {
2023-08-30 04:16:43 +02:00
pub id : i32 ,
pub name : String ,
}
2023-08-26 06:36:12 +02:00
#[ derive(Serialize, ToSchema, Debug, Clone) ]
2023-09-02 20:23:34 +02:00
pub struct ChellarisGame {
2023-08-26 06:36:12 +02:00
pub id : i32 ,
pub name : String ,
2023-09-02 20:23:34 +02:00
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 ,
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub game_id : i32
}
#[ derive(Serialize, Deserialize, ToSchema, Debug) ]
pub struct UpdateGroupParams {
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub group_id : i32 ,
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub game_id : i32 ,
#[ schema(example = " Group XY " ) ]
pub group_name : String
}
#[ derive(Serialize, Deserialize, ToSchema, Debug, IntoParams) ]
pub struct DeleteGroupParams {
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub group_id : i32 ,
2023-09-03 02:20:26 +02:00
#[ schema(example = 1) ]
2023-09-02 20:23:34 +02:00
pub game_id : i32 ,
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct ChellarisGroupFlat {
pub id : i32 ,
pub name : String ,
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct ChellarisGameGroupLegacy {
pub id : i32 ,
pub name : String ,
}
2023-09-03 02:20:26 +02:00
// Empire Structs
2023-09-07 20:14:51 +02:00
#[ derive(Serialize, Deserialize, ToSchema, Debug, IntoParams) ]
pub struct GetEmpireParams {
#[ schema(example = 1) ]
pub game_id : i32 ,
#[ schema(example = 1) ]
pub empire_id : i32 ,
}
2023-09-03 02:20:26 +02:00
#[ 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 empire_id : i32 ,
}
2023-09-02 20:23:34 +02:00
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct ChellarisEmpireFlat {
pub id : i32 ,
pub group : i32 ,
2023-09-03 02:20:26 +02:00
pub game : i32 ,
2023-09-02 20:23:34 +02:00
pub name : String ,
pub discord_user : Option < String > ,
pub gestalt : bool ,
2023-09-03 02:20:26 +02:00
pub portrait_id : i32 ,
pub portrait_group_id : i32 ,
2023-08-26 06:36:12 +02:00
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct ChellarisEmpire {
pub id : i32 ,
pub group : i32 ,
2023-09-03 02:20:26 +02:00
pub game : i32 ,
pub name : String ,
2023-08-26 06:36:12 +02:00
pub discord_user : Option < String > ,
2023-09-03 02:20:26 +02:00
pub gestalt : bool ,
pub portrait_id : i32 ,
pub portrait_group_id : i32 ,
2023-08-26 06:36:12 +02:00
pub ethics : HashMap < i32 , EmpireEthic > ,
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
2023-09-03 02:20:26 +02:00
pub struct ChellarisEmpireLegacy {
2023-08-26 06:36:12 +02:00
pub id : i32 ,
2023-09-03 02:20:26 +02:00
pub group : i32 ,
pub gestalt : bool ,
2023-08-26 06:36:12 +02:00
pub machine : bool ,
2023-09-03 02:20:26 +02:00
pub empire_portrait : i32 ,
pub empire_portrait_group : i32 ,
pub discord_user : Option < String > ,
pub ethics : HashMap < i32 , EmpireEthicLegacy > ,
2023-08-26 06:36:12 +02:00
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
2023-09-03 02:20:26 +02:00
pub struct Ethic {
pub id : i32 ,
pub display : String ,
pub machine : bool ,
}
#[ derive(Serialize, Deserialize, ToSchema, Debug, Clone) ]
2023-08-26 06:36:12 +02:00
pub struct EmpireEthic {
2023-09-03 02:20:26 +02:00
#[ schema(example = " 1 " ) ]
pub ethic_id : i32 ,
#[ schema(example = " true " ) ]
pub fanatic : bool ,
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct EmpireEthicLegacy {
2023-08-26 06:36:12 +02:00
pub id : i32 ,
2023-09-03 02:20:26 +02:00
pub display : String ,
2023-08-26 06:36:12 +02:00
pub machine : bool ,
pub fanatic : bool ,
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct Species {
pub id : i32 ,
2023-09-03 02:20:26 +02:00
pub display : String ,
2023-08-26 06:36:12 +02:00
pub portraits : HashMap < i32 , Portrait > ,
}
#[ derive(Serialize, ToSchema, Debug, Clone) ]
pub struct Portrait {
pub id : i32 ,
pub hires : String ,
pub lores : Option < String > ,
2023-08-30 04:16:43 +02:00
}