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,66 @@
|
||||
use actix_web::{HttpResponse, web};
|
||||
use serde::Deserialize;
|
||||
use utoipa::IntoParams;
|
||||
|
||||
use crate::api::response::{ApiErrorResponse, ApiResponse};
|
||||
use crate::error::AppError;
|
||||
use crate::models::issues::Issue;
|
||||
use crate::service::AppService;
|
||||
use crate::service::issues::core::UpdateIssueParams;
|
||||
use crate::session::Session;
|
||||
|
||||
#[derive(Debug, Deserialize, IntoParams)]
|
||||
pub struct PathParams {
|
||||
/// Workspace name (unique identifier)
|
||||
pub workspace_name: String,
|
||||
/// Issue number (unique within the workspace)
|
||||
pub number: i64,
|
||||
}
|
||||
|
||||
/// Update an issue
|
||||
///
|
||||
/// Updates an existing issue's metadata such as title, body, priority, visibility, due date, and milestone.
|
||||
/// Requires write access to the issue (author or workspace member).
|
||||
///
|
||||
/// All fields are optional; only provided fields are updated.
|
||||
/// Returns the updated issue with full metadata.
|
||||
#[utoipa::path(
|
||||
put,
|
||||
path = "/api/v1/workspaces/{workspace_name}/issues/{number}",
|
||||
tag = "Issues",
|
||||
operation_id = "issueUpdate",
|
||||
params(PathParams),
|
||||
request_body(
|
||||
content = UpdateIssueParams,
|
||||
description = "Issue update parameters (all fields optional)",
|
||||
content_type = "application/json"
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Issue updated successfully. Returns the updated issue with full metadata.", body = ApiResponse<Issue>),
|
||||
(status = 400, description = "Invalid parameters: invalid priority, visibility, or milestone", body = ApiErrorResponse),
|
||||
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
|
||||
(status = 403, description = "Insufficient permissions to edit this issue", body = ApiErrorResponse),
|
||||
(status = 404, description = "Workspace, issue, or referenced resource not found", body = ApiErrorResponse),
|
||||
(status = 500, description = "Internal server error", body = ApiErrorResponse),
|
||||
),
|
||||
security(
|
||||
("session_cookie" = [])
|
||||
)
|
||||
)]
|
||||
pub async fn update(
|
||||
service: web::Data<AppService>,
|
||||
session: Session,
|
||||
path: web::Path<PathParams>,
|
||||
params: web::Json<UpdateIssueParams>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let issue = service
|
||||
.issue
|
||||
.issue_update(
|
||||
&session,
|
||||
&path.workspace_name,
|
||||
path.number,
|
||||
params.into_inner(),
|
||||
)
|
||||
.await?;
|
||||
Ok(HttpResponse::Ok().json(ApiResponse::new(issue)))
|
||||
}
|
||||
Reference in New Issue
Block a user