Files
gitks/api/user/get_account.rs
T
zhenyi 4028f0d943 refactor(api): reorder imports and update code formatting across repository endpoints
- Reordered actix-web imports to standardize import order
- Reordered crate module imports to follow alphabetical ordering
- Updated function calls to use multi-line formatting for better readability
- Standardized blank lines around documentation comments
- Applied consistent formatting to response handling methods
- Normalized import organization across all repository-related API files
- Improved code consistency and maintainability through standardized formatting
- Applied formatting updates to all repository endpoint implementations
2026-06-07 19:41:33 +08:00

40 lines
1.3 KiB
Rust

use actix_web::{HttpResponse, web};
use crate::api::response::{ApiErrorResponse, ApiResponse};
use crate::error::AppError;
use crate::models::users::User;
use crate::service::AppService;
use crate::session::Session;
/// Get current user account
///
/// Returns the authenticated user's account information including:
/// - Username, display name, and bio
/// - Avatar URL
/// - Account status and role
/// - Last login and creation timestamps
///
/// Requires authentication.
#[utoipa::path(
get,
path = "/api/v1/user/account",
tag = "User",
operation_id = "userGetAccount",
responses(
(status = 200, description = "Account retrieved successfully. Returns user account with all metadata.", body = ApiResponse<User>),
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
(status = 404, description = "User not found", body = ApiErrorResponse),
(status = 500, description = "Internal server error", body = ApiErrorResponse),
),
security(
("session_cookie" = [])
)
)]
pub async fn get_account(
service: web::Data<AppService>,
session: Session,
) -> Result<HttpResponse, AppError> {
let user = service.user.user_account(&session).await?;
Ok(HttpResponse::Ok().json(ApiResponse::new(user)))
}