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:
zhenyi
2026-06-07 19:41:33 +08:00
parent 7368ba676c
commit 4028f0d943
149 changed files with 4962 additions and 369 deletions
+56
View File
@@ -0,0 +1,56 @@
use actix_web::{HttpResponse, web};
use crate::api::response::{ApiErrorResponse, ApiResponse};
use crate::error::AppError;
use crate::models::users::UserAppearance;
use crate::service::AppService;
use crate::service::user::appearance::UpdateUserAppearanceParams;
use crate::session::Session;
/// Update user appearance settings
///
/// Updates the authenticated user's UI appearance preferences.
/// Requires authentication.
///
/// Updatable fields:
/// - theme: UI theme ("system", "light", "dark")
/// - color_scheme: Color scheme ("system", "light", "dark")
/// - density: UI density ("compact", "comfortable")
/// - font_size: Font size ("small", "medium", "large")
/// - editor_theme: Code editor theme name
/// - markdown_preview: Enable/disable markdown live preview
/// - reduced_motion: Enable/disable reduced motion
///
/// All fields are optional; only provided fields are updated.
/// Returns the updated appearance settings.
#[utoipa::path(
put,
path = "/api/v1/user/appearance",
tag = "User",
operation_id = "userUpdateAppearance",
request_body(
content = UpdateUserAppearanceParams,
description = "Appearance update parameters (all fields optional)",
content_type = "application/json"
),
responses(
(status = 200, description = "Appearance settings updated successfully. Returns all updated UI preferences.", body = ApiResponse<UserAppearance>),
(status = 400, description = "Invalid parameters: unsupported theme, color scheme, density, or font size", 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_appearance(
service: web::Data<AppService>,
session: Session,
params: web::Json<UpdateUserAppearanceParams>,
) -> Result<HttpResponse, AppError> {
let appearance = service
.user
.user_update_appearance(&session, params.into_inner())
.await?;
Ok(HttpResponse::Ok().json(ApiResponse::new(appearance)))
}