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
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
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::service::user::account::UpdateUserAccountParams;
|
||||
use crate::session::Session;
|
||||
|
||||
/// Update user account
|
||||
///
|
||||
/// Updates the authenticated user's account settings.
|
||||
/// Requires authentication.
|
||||
///
|
||||
/// Updatable fields:
|
||||
/// - username: New username (must be unique across the platform)
|
||||
/// - display_name: Human-readable display name
|
||||
/// - bio: Short biography text
|
||||
/// - visibility: Profile visibility ("public", "private", or "internal")
|
||||
///
|
||||
/// All fields are optional; only provided fields are updated.
|
||||
/// Returns the updated user account with all metadata.
|
||||
#[utoipa::path(
|
||||
put,
|
||||
path = "/api/v1/user/account",
|
||||
tag = "User",
|
||||
operation_id = "userUpdateAccount",
|
||||
request_body(
|
||||
content = UpdateUserAccountParams,
|
||||
description = "Account update parameters (all fields optional)",
|
||||
content_type = "application/json"
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Account updated successfully. Returns updated user account with all metadata.", body = ApiResponse<User>),
|
||||
(status = 400, description = "Invalid parameters: empty username or unsupported visibility value", body = ApiErrorResponse),
|
||||
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
|
||||
(status = 404, description = "User not found", body = ApiErrorResponse),
|
||||
(status = 409, description = "Username already taken", body = ApiErrorResponse),
|
||||
(status = 500, description = "Internal server error", body = ApiErrorResponse),
|
||||
),
|
||||
security(
|
||||
("session_cookie" = [])
|
||||
)
|
||||
)]
|
||||
pub async fn update_account(
|
||||
service: web::Data<AppService>,
|
||||
session: Session,
|
||||
params: web::Json<UpdateUserAccountParams>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let user = service
|
||||
.user
|
||||
.user_update_account(&session, params.into_inner())
|
||||
.await?;
|
||||
Ok(HttpResponse::Ok().json(ApiResponse::new(user)))
|
||||
}
|
||||
Reference in New Issue
Block a user