get_ticket_by_id

Function get_ticket_by_id 

Source
pub async fn get_ticket_by_id(
    __arg0: Path<i32>,
    __arg1: State<Arc<AppState>>,
) -> Result<impl IntoResponse, (StatusCode, Json<Value>)>
Expand description

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 table.

§Arguments

  • 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
  • 404 Not Found if ticket doesn’t exist
  • 500 Internal Server Error if database error occurs

§Example Response

{
  "id": 1,
  "category": "maintenance",
  "betreff": "Broken light in room 101",
  "description": "The ceiling light is not working",
  "room": 101,
  "status": "open",
  "date": "2024-01-15T10:30:00Z",
  "user_id": 5,
  "user_first_name": "John",
  "user_last_name": "Doe"
}