this repo has no description
at main 162 lines 3.7 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 pub streak_freezes: i32, 38} 39 40#[derive(Debug, FromRow)] 41#[allow(dead_code)] 42pub struct LessonState { 43 pub user_id: String, 44 pub topic_id: String, 45 pub lesson_id: String, 46 pub current_index: i32, 47 pub hearts: i32, 48 pub correct_count: i32, 49 pub updated_at: String, 50} 51 52// --------------------------------------------------------------------------- 53// Request DTOs 54// --------------------------------------------------------------------------- 55 56#[derive(Debug, Deserialize)] 57pub struct RegisterRequest { 58 pub username: String, 59 pub email: String, 60 pub password: String, 61} 62 63#[derive(Debug, Deserialize)] 64pub struct LoginRequest { 65 pub email: String, 66 pub password: String, 67} 68 69#[derive(Debug, Deserialize)] 70pub struct ProgressUpdateRequest { 71 pub topic_id: String, 72 pub lesson_id: String, 73 pub score: i32, 74 pub xp_earned: i32, 75} 76 77#[derive(Debug, Deserialize)] 78pub struct LessonStateSaveRequest { 79 pub topic_id: String, 80 pub lesson_id: String, 81 pub current_index: i32, 82 pub hearts: i32, 83 pub correct_count: i32, 84} 85 86// --------------------------------------------------------------------------- 87// Response DTOs 88// --------------------------------------------------------------------------- 89 90#[derive(Debug, Serialize)] 91pub struct AuthResponse { 92 pub token: String, 93 pub user: UserResponse, 94} 95 96#[derive(Debug, Serialize)] 97pub struct UserResponse { 98 pub id: String, 99 pub username: String, 100 pub email: String, 101} 102 103#[derive(Debug, Serialize)] 104pub struct MeResponse { 105 pub user: UserResponse, 106 pub stats: StatsResponse, 107} 108 109#[derive(Debug, Serialize, Clone)] 110pub struct StatsResponse { 111 pub xp: i32, 112 pub streak_days: i32, 113 pub hearts: i32, 114 pub streak_freezes: i32, 115} 116 117#[derive(Debug, Serialize)] 118pub struct ProgressResponse { 119 pub lessons: Vec<LessonProgress>, 120 pub stats: StatsResponse, 121} 122 123#[derive(Debug, Serialize)] 124pub struct LessonProgress { 125 pub topic_id: String, 126 pub lesson_id: String, 127 pub completed: bool, 128 pub best_score: i32, 129 pub completed_at: Option<String>, 130} 131 132#[derive(Debug, Serialize)] 133pub struct LessonStateResponse { 134 pub topic_id: String, 135 pub lesson_id: String, 136 pub current_index: i32, 137 pub hearts: i32, 138 pub correct_count: i32, 139} 140 141// --------------------------------------------------------------------------- 142// Push notification DTOs 143// --------------------------------------------------------------------------- 144 145#[derive(Debug, Deserialize)] 146pub struct PushSubscribeRequest { 147 pub endpoint: String, 148 pub p256dh: String, 149 pub auth: String, 150} 151 152#[derive(Debug, Deserialize)] 153pub struct PushPreferencesRequest { 154 pub reminder_enabled: bool, 155 pub reminder_time: String, 156} 157 158#[derive(Debug, Serialize)] 159pub struct PushPreferencesResponse { 160 pub reminder_enabled: bool, 161 pub reminder_time: String, 162}