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,57 @@
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
use crate::api::response::{ApiErrorResponse, ApiResponse};
|
||||
use crate::error::AppError;
|
||||
use crate::models::users::UserProfile;
|
||||
use crate::service::AppService;
|
||||
use crate::service::user::profile::UpdateUserProfileParams;
|
||||
use crate::session::Session;
|
||||
|
||||
/// Update user profile
|
||||
///
|
||||
/// Updates the authenticated user's public profile information.
|
||||
/// Requires authentication.
|
||||
///
|
||||
/// Updatable fields:
|
||||
/// - full_name: Full legal name or display name
|
||||
/// - company: Organization or company name
|
||||
/// - location: Geographic location (e.g., "San Francisco, CA")
|
||||
/// - website_url: Personal or company website URL
|
||||
/// - twitter_username: Twitter/X handle
|
||||
/// - timezone: IANA timezone identifier (e.g., "America/New_York")
|
||||
/// - language: Preferred language code (e.g., "en", "zh-CN")
|
||||
/// - profile_readme: Markdown content for profile README
|
||||
///
|
||||
/// All fields are optional; only provided fields are updated.
|
||||
/// Returns the updated profile with all fields.
|
||||
#[utoipa::path(
|
||||
put,
|
||||
path = "/api/v1/user/profile",
|
||||
tag = "User",
|
||||
operation_id = "userUpdateProfile",
|
||||
request_body(
|
||||
content = UpdateUserProfileParams,
|
||||
description = "Profile update parameters (all fields optional)",
|
||||
content_type = "application/json"
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Profile updated successfully. Returns all updated profile fields.", body = ApiResponse<UserProfile>),
|
||||
(status = 400, description = "Invalid parameters", body = ApiErrorResponse),
|
||||
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
|
||||
(status = 500, description = "Internal server error", body = ApiErrorResponse),
|
||||
),
|
||||
security(
|
||||
("session_cookie" = [])
|
||||
)
|
||||
)]
|
||||
pub async fn update_profile(
|
||||
service: web::Data<AppService>,
|
||||
session: Session,
|
||||
params: web::Json<UpdateUserProfileParams>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let profile = service
|
||||
.user
|
||||
.user_update_profile(&session, params.into_inner())
|
||||
.await?;
|
||||
Ok(HttpResponse::Ok().json(ApiResponse::new(profile)))
|
||||
}
|
||||
Reference in New Issue
Block a user