gitdataai/libs/api/user/summary.rs

26 lines
836 B
Rust

use crate::{ApiResponse, error::ApiError};
use actix_web::{HttpResponse, Result, web};
use service::AppService;
use session::Session;
#[utoipa::path(
get,
path = "/api/users/{username}/summary",
params(("username" = String, Path)),
responses(
(status = 200, description = "Get user summary for dashboard", body = ApiResponse<service::user::summary::UserSummaryResponse>),
(status = 401, description = "Unauthorized"),
(status = 404, description = "Not found"),
),
tag = "User"
)]
pub async fn get_user_summary(
service: web::Data<AppService>,
session: Session,
path: web::Path<String>,
) -> Result<HttpResponse, ApiError> {
let username = path.into_inner();
let resp = service.user_get_summary(session, username).await?;
Ok(ApiResponse::ok(resp).to_response())
}