this repo has no description
at edge-tts 107 lines 2.4 kB view raw
1use serde::{Deserialize, Serialize}; 2use sqlx::FromRow; 3 4// --------------------------------------------------------------------------- 5// Database models 6// --------------------------------------------------------------------------- 7 8#[derive(Debug, FromRow)] 9#[allow(dead_code)] 10pub struct User { 11 pub id: String, 12 pub username: String, 13 pub email: String, 14 pub password_hash: String, 15 pub created_at: String, 16} 17 18#[derive(Debug, FromRow)] 19#[allow(dead_code)] 20pub struct Progress { 21 pub user_id: String, 22 pub topic_id: String, 23 pub lesson_id: String, 24 pub completed: i32, 25 pub best_score: i32, 26 pub completed_at: Option<String>, 27} 28 29#[derive(Debug, FromRow)] 30#[allow(dead_code)] 31pub struct UserStats { 32 pub user_id: String, 33 pub xp: i32, 34 pub streak_days: i32, 35 pub last_active_date: Option<String>, 36 pub hearts: i32, 37} 38 39// --------------------------------------------------------------------------- 40// Request DTOs 41// --------------------------------------------------------------------------- 42 43#[derive(Debug, Deserialize)] 44pub struct RegisterRequest { 45 pub username: String, 46 pub email: String, 47 pub password: String, 48} 49 50#[derive(Debug, Deserialize)] 51pub struct LoginRequest { 52 pub email: String, 53 pub password: String, 54} 55 56#[derive(Debug, Deserialize)] 57pub struct ProgressUpdateRequest { 58 pub topic_id: String, 59 pub lesson_id: String, 60 pub score: i32, 61 pub xp_earned: i32, 62} 63 64// --------------------------------------------------------------------------- 65// Response DTOs 66// --------------------------------------------------------------------------- 67 68#[derive(Debug, Serialize)] 69pub struct AuthResponse { 70 pub token: String, 71 pub user: UserResponse, 72} 73 74#[derive(Debug, Serialize)] 75pub struct UserResponse { 76 pub id: String, 77 pub username: String, 78 pub email: String, 79} 80 81#[derive(Debug, Serialize)] 82pub struct MeResponse { 83 pub user: UserResponse, 84 pub stats: StatsResponse, 85} 86 87#[derive(Debug, Serialize, Clone)] 88pub struct StatsResponse { 89 pub xp: i32, 90 pub streak_days: i32, 91 pub hearts: i32, 92} 93 94#[derive(Debug, Serialize)] 95pub struct ProgressResponse { 96 pub lessons: Vec<LessonProgress>, 97 pub stats: StatsResponse, 98} 99 100#[derive(Debug, Serialize)] 101pub struct LessonProgress { 102 pub topic_id: String, 103 pub lesson_id: String, 104 pub completed: bool, 105 pub best_score: i32, 106 pub completed_at: Option<String>, 107}