use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use sqlx::FromRow; use utoipa::ToSchema; /// User model representing the users table #[derive(Debug, Clone, Serialize, Deserialize, FromRow, ToSchema)] pub struct User { pub id: i32, pub date_registered: DateTime, pub firstname: String, pub lastname: String, pub username: String, pub email: String, #[serde(skip_serializing)] pub password: String, pub is_admin: bool, pub profile: Option, #[serde(skip_serializing)] pub password_reset_token: Option, // OpenSkill rating fields pub mu: Option, pub sigma: Option, pub ordinal: Option, pub mmr: Option, } /// User public profile (without sensitive data) #[derive(Debug, Clone, Serialize, ToSchema)] pub struct UserProfile { pub id: i32, pub date_registered: DateTime, pub firstname: String, pub lastname: String, pub username: String, pub profile: Option, pub mu: f64, pub sigma: f64, pub ordinal: f64, pub mmr: f64, } impl From for UserProfile { fn from(user: User) -> Self { Self { id: user.id, date_registered: user.date_registered, firstname: user.firstname, lastname: user.lastname, username: user.username, profile: user.profile, mu: user.mu.unwrap_or(25.0) as f64, sigma: user.sigma.unwrap_or(8.333333) as f64, ordinal: user.ordinal.unwrap_or(0.0) as f64, mmr: user.mmr.unwrap_or(1500.0) as f64, } } } /// Create user request (internal use) #[derive(Debug, Deserialize, ToSchema)] pub struct CreateUser { pub firstname: String, pub lastname: String, pub username: String, pub email: String, pub password: String, } /// Update user request #[derive(Debug, Deserialize, ToSchema)] pub struct UpdateUser { pub firstname: Option, pub lastname: Option, pub username: Option, pub profile: Option, } /// Player stats response #[derive(Debug, Clone, Serialize, ToSchema)] pub struct PlayerStats { pub id: i32, pub username: String, pub firstname: String, pub lastname: String, pub profile: Option, pub mu: f64, pub sigma: f64, pub ordinal: f64, pub mmr: f64, pub team_id: Option, pub team_name: Option, pub position: Option, }