2023-12-12 20:39:15 +01:00
use std ::collections ::HashMap ;
use serde ::{ Deserialize , Serialize } ;
2023-12-12 20:49:39 +01:00
use utoipa ::{ ToSchema } ;
2023-12-12 20:39:15 +01:00
// DB Permission Enums
pub enum TablePermission {
Game ,
Empire ,
Data ,
User
}
// User Structs
#[ derive(Serialize, ToSchema, Debug) ]
pub struct User {
#[ schema(example = " abcdef " ) ]
pub user_token : String ,
#[ schema(example = " discorduser " ) ]
pub discord_handle : Option < String > ,
#[ schema(example = " /assets/avatars/124677612.png " ) ]
pub profile_picture : Option < String > ,
#[ schema(example = " \
{ \
[ \ " game_permissions \" ]: true,
[ \ " empire_permissions \" ]: true,
[ \ " data_permissions \" ]: false,
[ \ " user_permissions \" ]: false,
} \
" )]
pub permissions : HashMap < String , bool > ,
}
#[ derive(Serialize, Deserialize, ToSchema, Debug) ]
pub struct GetUserParams {
#[ schema(example = " abcdef " ) ]
pub user_token : String ,
}
#[ derive(Serialize, Deserialize, ToSchema, Debug) ]
pub struct UpdateUserParams {
#[ schema(example = " abcdef " ) ]
pub user_token : String ,
#[ schema(example = " discorduser " ) ]
pub discord_handle : Option < String > ,
#[ schema(example = " /assets/avatars/124677612.png " ) ]
pub profile_picture : Option < String > ,
#[ schema(example = " \
{ \
[ \ " game_permissions \" ]: true,
[ \ " empire_permissions \" ]: true,
[ \ " data_permissions \" ]: false,
[ \ " user_permissions \" ]: false,
} \
" )]
pub permissions : HashMap < String , bool > ,
}
#[ derive(Serialize, Deserialize, ToSchema, Debug) ]
pub struct DeleteUserParams {
#[ schema(example = " abcdef " ) ]
pub user_token : String ,
}