Files
vrbattles-api/src/models/team_player.rs
VinceC cac4b83140 Add utoipa and Scalar for API documentation
- Add utoipa and utoipa-scalar dependencies
- Add ToSchema derives to all models
- Add OpenAPI path annotations to auth, users, and health handlers
- Create openapi.rs module with API documentation
- Serve Scalar UI at /docs endpoint
- Include JWT bearer auth security scheme

Co-Authored-By: Warp <agent@warp.dev>
2026-01-20 01:30:10 -06:00

73 lines
1.8 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use utoipa::ToSchema;
/// Team player positions
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, ToSchema)]
#[serde(rename_all = "lowercase")]
pub enum PlayerPosition {
Captain,
#[serde(rename = "co-captain")]
CoCaptain,
Member,
}
impl PlayerPosition {
pub fn as_str(&self) -> &'static str {
match self {
PlayerPosition::Captain => "captain",
PlayerPosition::CoCaptain => "co-captain",
PlayerPosition::Member => "member",
}
}
pub fn from_str(s: &str) -> Option<Self> {
match s.to_lowercase().as_str() {
"captain" => Some(PlayerPosition::Captain),
"co-captain" => Some(PlayerPosition::CoCaptain),
"member" => Some(PlayerPosition::Member),
_ => None,
}
}
}
/// Team player status
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, ToSchema)]
pub enum TeamPlayerStatus {
Pending = 0,
Active = 1,
}
impl From<i32> for TeamPlayerStatus {
fn from(val: i32) -> Self {
match val {
1 => TeamPlayerStatus::Active,
_ => TeamPlayerStatus::Pending,
}
}
}
/// Team player model representing the team_players table
#[derive(Debug, Clone, Serialize, Deserialize, FromRow, ToSchema)]
pub struct TeamPlayer {
pub id: i32,
pub date_created: DateTime<Utc>,
pub team_id: i32,
pub player_id: i32,
pub position: String,
pub status: i32,
}
/// Join team request
#[derive(Debug, Deserialize, ToSchema)]
pub struct JoinTeamRequest {
pub team_id: i32,
}
/// Change position request
#[derive(Debug, Deserialize, ToSchema)]
pub struct ChangePositionRequest {
pub position: String,
}