(
conn: Connection<Db>,
id: i32,
post_data: DataResult<'_, post::Model>,
)
| 50 | #[openapi(tag = "POST")] |
| 51 | #[post("/<id>", data = "<post_data>")] |
| 52 | async fn update( |
| 53 | conn: Connection<Db>, |
| 54 | id: i32, |
| 55 | post_data: DataResult<'_, post::Model>, |
| 56 | ) -> R<Option<String>> { |
| 57 | let db = conn.into_inner(); |
| 58 | |
| 59 | let form = post_data?.into_inner(); |
| 60 | |
| 61 | let cmd = Mutation::update_post_by_id(&db, id, form); |
| 62 | match cmd.await { |
| 63 | Ok(_) => Ok(Json(Some("Post successfully updated.".to_string()))), |
| 64 | Err(e) => { |
| 65 | let m = error::Error { |
| 66 | err: "Could not update post".to_string(), |
| 67 | msg: Some(e.to_string()), |
| 68 | http_status_code: 400, |
| 69 | }; |
| 70 | Err(m) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /// # Get post list |
| 76 | #[openapi(tag = "POST")] |
nothing calls this directly
no test coverage detected