use axum::extract::{Json, Path, State}; use export::rest::{AppResponseData, NoData}; use jwt::Session; use crate::errors::ApiError; use crate::services::comments::{CommentDto, CreateCommentCmd}; use crate::services::issues::IssuePath; use crate::services::service::IssueService; use jwt::share::session::require_uid; #[utoipa::path( post, path = "/issues/{space_name}/boards/{board_id}/issues/{issue_id}/comments", tag = "issues", description = "在议题下新增评论或回复,并处理提及与通知。", params(IssuePath), request_body = CreateCommentCmd, responses( (status = 200, description = "create comment", body = AppResponseData), (status = 429, description = "creation quota exceeded", body = AppResponseData), (status = 400, description = "bad request", body = AppResponseData), (status = 403, description = "forbidden", body = AppResponseData), (status = 404, description = "not found", body = AppResponseData), (status = 409, description = "resource already exists", body = AppResponseData), (status = 401, description = "authentication required", body = AppResponseData) ) )] pub async fn create_comment( State(service): State, session: Session, Path(path): Path, Json(cmd): Json, ) -> Result, ApiError> { let uid = require_uid(&session)?; let issue_id = service .resolve_issue_ref(uid, &path.space_name, path.board_id, &path.issue_id) .await?; let dto = service .create_comment(uid, &path.space_name, path.board_id, issue_id, cmd) .await?; Ok(AppResponseData::ok(dto)) }