80 lines
2.7 KiB
Rust
80 lines
2.7 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
// --- DB rows ---
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Course { pub id: i64, pub name: String, pub semester: String }
|
|
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Tutor {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub email: String,
|
|
pub is_superadmin: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Student { pub id: i64, pub course_id: i64, pub name: String }
|
|
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Room { pub id: i64, pub name: String, pub layout_json: String }
|
|
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Session {
|
|
pub id: i64, pub course_id: i64,
|
|
pub week_nr: i64, pub date: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Slot {
|
|
pub id: i64, pub session_id: i64,
|
|
pub room_id: Option<i64>, pub tutor_id: i64,
|
|
pub start_time: String, pub end_time: String,
|
|
pub status: String, pub code: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Attendance {
|
|
pub id: i64, pub slot_id: i64, pub student_id: i64,
|
|
pub seat_id: Option<String>, pub checked_in_at: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
|
|
pub struct Note {
|
|
pub id: i64, pub slot_id: i64, pub student_id: i64,
|
|
pub tutor_id: i64, pub content: String, pub updated_at: String,
|
|
}
|
|
|
|
// --- Layout element (nested in Room) ---
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct LayoutElement {
|
|
pub id: String, pub label: String,
|
|
pub x: f64, pub y: f64,
|
|
pub width: f64, pub height: f64,
|
|
#[serde(rename = "type")]
|
|
pub kind: String, // "seat" | "table" | "gap" | "door"
|
|
}
|
|
|
|
// --- Request types ---
|
|
#[derive(Deserialize)] pub struct CreateCourse { pub name: String, pub semester: String }
|
|
#[derive(Deserialize)] pub struct CreateStudent { pub name: String }
|
|
#[derive(Deserialize)] pub struct CreateRoom { pub name: String, pub layout: Vec<LayoutElement> }
|
|
#[derive(Deserialize)] pub struct CreateSession { pub course_id: i64, pub week_nr: i64, pub date: String }
|
|
#[derive(Deserialize)] pub struct CreateSlot {
|
|
pub session_id: i64, pub room_id: Option<i64>, pub tutor_id: i64,
|
|
pub start_time: String, pub end_time: String,
|
|
}
|
|
#[derive(Deserialize)] pub struct UpsertNote { pub content: String }
|
|
#[derive(Deserialize)] pub struct ManualAttendance { pub student_id: i64 }
|
|
#[derive(Deserialize)] pub struct CreateTutor {
|
|
pub name: String,
|
|
pub email: String,
|
|
pub password: String,
|
|
pub is_superadmin: bool,
|
|
}
|
|
#[derive(Deserialize)] pub struct AssignTutor { pub tutor_id: i64 }
|
|
#[derive(Deserialize)] pub struct CheckinRequest {
|
|
pub code: String,
|
|
pub student_id: i64,
|
|
pub seat_id: Option<String>,
|
|
}
|