Refined docs and stuff

Docs link to each other and are generally better
This commit is contained in:
2026-05-20 12:50:00 +02:00
parent 0db9b76cad
commit 721e43c380
14 changed files with 256 additions and 159 deletions

View File

@@ -16,12 +16,14 @@ use crate::{
/// Creates a new support ticket.
///
/// Associates the ticket with the authenticated user and sets the current timestamp.
/// Associates the ticket with the authenticated [`FilteredUser`] and sets the current timestamp.
/// Converts the [`TicketCreateScheme`] request into a database record.
/// Tickets are automatically created with "open" status.
///
/// # Arguments
/// - `user`: Authenticated user (extracted from JWT token)
/// - `body`: Ticket details (category, subject, description, room)
/// - `Extension(user)`: Authenticated [`FilteredUser`] (extracted from JWT token via middleware)
/// - `State(data)`: Application state containing [`AppState`] for database access
/// - `Json(body)`: [`TicketCreateScheme`] containing ticket details (category, subject, description, room)
///
/// # Returns
/// - `200 OK` on successful creation
@@ -60,10 +62,11 @@ pub async fn create_ticket(
/// Deletes a ticket by ID.
///
/// Only admins can delete tickets. Marks the ticket as deleted or removes from database.
/// Only admins can delete tickets (enforced by middleware). Removes the [`TicketResponse`] and associated data from the database.
///
/// # Arguments
/// - `id`: Ticket ID to delete
/// - `Path(id)`: Ticket ID to delete, extracted from URL path
/// - `State(data)`: Application state containing [`AppState`] for database access
///
/// # Returns
/// - `204 No Content` on successful deletion
@@ -97,15 +100,18 @@ pub async fn delete_ticket(
/// Retrieves all non-archived tickets.
///
/// Returns a list of all active tickets with user information denormalized for easier rendering.
/// Tickets are ordered by creation date (newest first).
/// Returns a list of all active [`TicketResponse`] objects with user information denormalized for easier rendering.
/// Tickets are ordered by creation date (newest first). Joins with [`User`](crate::models::User) table to include creator information.
///
/// # Arguments
/// - `State(data)`: Application state containing [`AppState`] for database access
///
/// # Filtering
/// - Excludes tickets with status "Archived"
/// - Uses LEFT JOIN to include creator information
/// - Uses LEFT JOIN to include creator information from [`User`](crate::models::User)
///
/// # Returns
/// - `200 OK` with array of TicketResponse objects
/// - `200 OK` with array of [`TicketResponse`] objects
/// - `500 Internal Server Error` if database query fails
///
/// # Example Response
@@ -169,12 +175,14 @@ pub async fn get_tickets(
/// Retrieves a specific ticket by ID.
///
/// Includes full ticket details and denormalized user information (creator name).
/// Returns a [`TicketResponse`] with all metadata by joining with [`User`](crate::models::User) table.
///
/// # Arguments
/// - `id`: Ticket ID to retrieve
/// - `Path(id)`: Ticket ID to retrieve, extracted from URL path
/// - `State(data)`: Application state containing [`AppState`] for database access
///
/// # Returns
/// - `200 OK` with TicketResponse object
/// - `200 OK` with [`TicketResponse`] object
/// - `404 Not Found` if ticket doesn't exist
/// - `500 Internal Server Error` if database error occurs
///
@@ -242,15 +250,16 @@ pub async fn get_ticket_by_id(
/// Updates a ticket's status.
///
/// Only admins can update ticket status. This is typically used to transition tickets
/// through their lifecycle (open → in_progress → resolved → archived).
/// Only admins can update ticket status (enforced by middleware). Applies [`TicketUpdateScheme`] to modify the [`TicketResponse`].
/// This is typically used to transition tickets through their lifecycle (open → in_progress → resolved → archived).
///
/// # Arguments
/// - `id`: Ticket ID to update
/// - `body`: Update payload containing new status
/// - `Path(id)`: Ticket ID to update, extracted from URL path
/// - `State(data)`: Application state containing [`AppState`] for database access
/// - `Json(body)`: [`TicketUpdateScheme`] update payload containing new status
///
/// # Returns
/// - `200 OK` with updated TicketResponse
/// - `200 OK` with updated [`TicketResponse`]
/// - `500 Internal Server Error` if ticket not found or database error
///
/// # Typical Status Flow