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,59 @@
|
||||
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::IssueLabelRelation;
|
||||
use crate::service::AppService;
|
||||
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,
|
||||
/// Label ID (UUID) to assign
|
||||
pub label_id: uuid::Uuid,
|
||||
}
|
||||
|
||||
/// Assign a label to an issue
|
||||
///
|
||||
/// Attaches a label to the given issue. The label must belong to a repository in the same workspace.
|
||||
/// Requires write access to the issue (author or workspace member).
|
||||
///
|
||||
/// Effects:
|
||||
/// - Label is attached to the issue
|
||||
/// - Issue label count is incremented
|
||||
///
|
||||
/// Returns the created label relation.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/workspaces/{workspace_name}/issues/{number}/labels/{label_id}",
|
||||
tag = "Issues",
|
||||
operation_id = "issueAssignLabel",
|
||||
params(PathParams),
|
||||
responses(
|
||||
(status = 200, description = "Label assigned successfully. Returns the created label relation.", body = ApiResponse<IssueLabelRelation>),
|
||||
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
|
||||
(status = 403, description = "Insufficient permissions to edit this issue", body = ApiErrorResponse),
|
||||
(status = 404, description = "Issue or label not found", body = ApiErrorResponse),
|
||||
(status = 409, description = "Label is already assigned to this issue", body = ApiErrorResponse),
|
||||
(status = 500, description = "Internal server error", body = ApiErrorResponse),
|
||||
),
|
||||
security(
|
||||
("session_cookie" = [])
|
||||
)
|
||||
)]
|
||||
pub async fn assign_label(
|
||||
service: web::Data<AppService>,
|
||||
session: Session,
|
||||
path: web::Path<PathParams>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let rel = service
|
||||
.issue
|
||||
.issue_assign_label(&session, &path.workspace_name, path.number, path.label_id)
|
||||
.await?;
|
||||
Ok(HttpResponse::Ok().json(ApiResponse::new(rel)))
|
||||
}
|
||||
Reference in New Issue
Block a user