diff --git a/backend/src/models.rs b/backend/src/models.rs index 2618982..ce3c8b1 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -1 +1,67 @@ -// models — populated in Task 3 +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 } + +#[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, pub tutor_id: i64, + pub start_time: String, pub end_time: String, + pub status: String, pub code: Option, +} + +#[derive(Debug, Clone, Serialize, sqlx::FromRow)] +pub struct Attendance { + pub id: i64, pub slot_id: i64, pub student_id: i64, + pub seat_id: Option, 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 } +#[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, 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 CheckinRequest { + pub code: String, + pub student_id: i64, + pub seat_id: Option, +}