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,60 @@
|
||||
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::IssueAssignee;
|
||||
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,
|
||||
/// User ID (UUID) to assign
|
||||
pub user_id: uuid::Uuid,
|
||||
}
|
||||
|
||||
/// Assign a user to an issue
|
||||
///
|
||||
/// Assigns a workspace member to the given issue.
|
||||
/// Requires write access to the issue (author or workspace member).
|
||||
///
|
||||
/// Effects:
|
||||
/// - User is assigned to the issue
|
||||
/// - Assignee is automatically subscribed to the issue
|
||||
/// - Issue assignee count is incremented
|
||||
///
|
||||
/// Returns the created assignment record.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/workspaces/{workspace_name}/issues/{number}/assignees/{user_id}",
|
||||
tag = "Issues",
|
||||
operation_id = "issueAssign",
|
||||
params(PathParams),
|
||||
responses(
|
||||
(status = 201, description = "User assigned successfully. Returns the created assignment record.", body = ApiResponse<IssueAssignee>),
|
||||
(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 user not found", body = ApiErrorResponse),
|
||||
(status = 409, description = "User is already assigned to this issue", body = ApiErrorResponse),
|
||||
(status = 500, description = "Internal server error", body = ApiErrorResponse),
|
||||
),
|
||||
security(
|
||||
("session_cookie" = [])
|
||||
)
|
||||
)]
|
||||
pub async fn assign_issue(
|
||||
service: web::Data<AppService>,
|
||||
session: Session,
|
||||
path: web::Path<PathParams>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let assignee = service
|
||||
.issue
|
||||
.issue_assign(&session, &path.workspace_name, path.number, path.user_id)
|
||||
.await?;
|
||||
Ok(HttpResponse::Created().json(ApiResponse::new(assignee)))
|
||||
}
|
||||
Reference in New Issue
Block a user