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
+55
View File
@@ -0,0 +1,55 @@
use actix_web::{HttpResponse, web};
use serde::Deserialize;
use utoipa::IntoParams;
use crate::api::response::{ApiErrorResponse, ApiResponse};
use crate::error::AppError;
use crate::service::AppService;
use crate::session::Session;
#[derive(Debug, Deserialize, IntoParams)]
pub struct PathParams {
/// Token ID (UUID)
pub token_id: uuid::Uuid,
}
/// Revoke a personal access token
///
/// Immediately revokes a personal access token belonging to the authenticated user.
/// Requires authentication.
///
/// Effects:
/// - Token is marked as revoked and can no longer be used
/// - All API calls using this token will fail with 401 Unauthorized
/// - Revoked tokens remain visible in token list for audit purposes
///
/// Returns success message on completion.
#[utoipa::path(
delete,
path = "/api/v1/user/security/tokens/{token_id}",
tag = "User",
operation_id = "userRevokeToken",
params(PathParams),
responses(
(status = 200, description = "Personal access token revoked successfully.", body = ApiResponse<String>),
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
(status = 404, description = "Token not found or already revoked", body = ApiErrorResponse),
(status = 500, description = "Internal server error", body = ApiErrorResponse),
),
security(
("session_cookie" = [])
)
)]
pub async fn revoke_token(
service: web::Data<AppService>,
session: Session,
path: web::Path<PathParams>,
) -> Result<HttpResponse, AppError> {
service
.user
.user_revoke_personal_access_token(&session, path.token_id)
.await?;
Ok(HttpResponse::Ok().json(ApiResponse::new(
"Personal access token revoked successfully".to_string(),
)))
}