pub async fn get_user_modules(
__arg0: State<AppState>,
__arg1: Path<i64>,
) -> impl IntoResponse
Expand description
GET /api/users/{user_id}/modules
Retrieve all modules that a specific user is involved in, including their role in each module. Requires admin privileges.
§Path Parameters
id
: The ID of the user to fetch modules for
§Responses
200 OK
{
"success": true,
"data": [
{
"id": 1,
"code": "COS301",
"year": 2025,
"description": "Advanced Software Engineering",
"credits": 16,
"role": "Lecturer",
"created_at": "2025-05-01T08:00:00Z",
"updated_at": "2025-05-01T08:00:00Z"
}
],
"message": "Modules for user retrieved successfully"
}
400 Bad Request
(invalid ID format)
{
"success": false,
"message": "Invalid user ID format"
}
403 Forbidden
- Not an admin user404 Not Found
- User not found
{
"success": false,
"message": "User not found"
}
500 Internal Server Error
- Database error
{
"success": false,
"message": "Database error: detailed error here"
}