Function get_my_details

Source
pub async fn get_my_details(
    __arg0: State<AppState>,
    __arg1: Extension<AuthUser>,
) -> impl IntoResponse
Expand description

GET /api/modules/me

Retrieves detailed information about the modules the authenticated user is assigned to.

§Arguments

This endpoint requires authentication. The user ID is automatically extracted from the JWT token.

§Returns

Returns an HTTP response indicating the result:

  • 200 OK with the user’s module assignments organized by role if successful.
  • 500 INTERNAL SERVER ERROR if a database error occurs while retrieving the module details.

The response body contains:

  • as_student: List of modules where the user is assigned as a student.
  • as_tutor: List of modules where the user is assigned as a tutor.
  • as_lecturer: List of modules where the user is assigned as a lecturer.
  • as_assistant_lecturer: List of modules where the user is assigned as an assistant lecturer.

§Example Response

  • 200 OK
{
  "success": true,
  "data": {
    "as_student": [
      { "id": 1, "code": "CS101", "year": 2024, "description": "...", "credits": 15, "created_at": "...", "updated_at": "..." }
    ],
    "as_tutor": [
      { "id": 2, "code": "CS201", "year": 2024, "description": "...", "credits": 20, "created_at": "...", "updated_at": "..." }
    ],
    "as_lecturer": [],
    "as_assistant_lecturer": []
  },
  "message": "My module details retrieved successfully"
}
  • 500 Internal Server Error
{
  "success": false,
  "message": "An error occurred while retrieving module details"
}