ff5ad26cfc
- Switched to secure httpOnly, SameSite=Strict cookies for JWT authentication. - Refactored backend to use AppState for shared secrets and database pool caching. - Modernized frontend with Svelte 5 runes ($state) and removed localStorage reliance. - Gated destructive test endpoints behind debug_assertions and fixed unsafe test patterns. - Enhanced CI pipeline with cargo clippy, cargo fmt, and pinned pnpm version. - Updated documentation and implementation plans to match the hardened architecture.
139 lines
2.9 KiB
Rust
139 lines
2.9 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>,
|
|
}
|