feat(project): add documents update handler
zhenyi committed
Added lib/project/handler/documents/update.rs lib/project/handler/documents/update.rs +28 −0 View lib/project/handler/documents/update.rs
@@ -0,0 +1,28 @@
1use axum::extract::{Path, State};
2use export::data::{AppRequest, AppRequestData, AppResponseData};
3use jwt::extractor::AuthUser;
4
5use crate::error::ProjectResult;
6use crate::features::ProjectService;
7use crate::features::documents::{DocumentView, UpdateDocumentCmd};
8use crate::handler::query::DocumentPath;
9
10#[utoipa::path(
11 patch,
12 path = "/spaces/{space_id}/projects/{project_id}/documents/{doc_id}",
13 tag = "project",
14 request_body = AppRequestData<UpdateDocumentCmd>,
15 responses((status = 200, description = "Update a document", body = AppResponseData<DocumentView>)),
16 security(("bearer_auth" = []))
17)]
18pub(crate) async fn handler(
19 State(svc): State<ProjectService>,
20 AuthUser { claims }: AuthUser,
21 Path(path): Path<DocumentPath>,
22 input: AppRequest<UpdateDocumentCmd>,
23) -> ProjectResult<AppResponseData<DocumentView>> {
24 let view = svc
25 .update_document(claims.sub, path.space_id, path.project_id, path.doc_id, input.into_inner())
26 .await?;
27 Ok(AppResponseData::ok(view))
28}
No newline at end of file