use crate::{ApiResponse, error::ApiError}; use actix_web::{HttpResponse, Result, web}; use service::AppService; use session::Session; #[utoipa::path( get, path = "/api/projects/{project_name}/join-requests/{request_id}/answers", params( ("project_name" = String, Path), ("request_id" = i64, Path), ), responses( (status = 200, description = "Get join request answers", body = ApiResponse), (status = 401, description = "Unauthorized"), (status = 403, description = "Forbidden"), (status = 404, description = "Not found"), ), tag = "Project" )] pub async fn project_join_answers( service: web::Data, session: Session, path: web::Path<(String, i64)>, ) -> Result { let (project_name, request_id) = path.into_inner(); let resp = service .project_get_join_answers(project_name, request_id, &session) .await?; Ok(ApiResponse::ok(resp).to_response()) } #[utoipa::path( post, path = "/api/projects/{project_name}/join-requests/{request_id}/answers", params( ("project_name" = String, Path), ("request_id" = i64, Path), ), request_body = Vec, responses( (status = 200, description = "Submit join request answers"), (status = 401, description = "Unauthorized"), (status = 404, description = "Not found"), ), tag = "Project" )] pub async fn project_submit_join_answers( service: web::Data, session: Session, path: web::Path<(String, i64)>, body: web::Json>, ) -> Result { let (project_name, request_id) = path.into_inner(); service .project_submit_join_answers(project_name, request_id, body.into_inner(), &session) .await?; Ok(ApiResponse::ok(serde_json::json!({ "success": true })).to_response()) }