diff --git a/src/api/posts/delete.rs b/src/api/posts/delete.rs index bfc0aba..b4f4dbe 100644 --- a/src/api/posts/delete.rs +++ b/src/api/posts/delete.rs @@ -25,12 +25,13 @@ pub async fn delete_post(post_id: i32) -> Result Result Result = tag_rows.iter().map(|r| r.get(0)).collect(); // 软删除:仅影响未被删除的文章。 - let result = client + let result = tx .execute( "UPDATE posts SET deleted_at = NOW() WHERE id = $1 AND deleted_at IS NULL", &[&post_id], ) .await - .map_err(AppError::query)?; + .map_err(AppError::tx)?; if result == 0 { return Ok(CreatePostResponse { @@ -73,6 +74,8 @@ pub async fn delete_post(post_id: i32) -> Result Result Result Result Result = tag_rows.iter().map(|r| r.get(0)).collect(); - let result = client + let result = tx .execute( "DELETE FROM posts WHERE id = $1 AND deleted_at IS NOT NULL", &[&post_id], ) .await - .map_err(AppError::query)?; + .map_err(AppError::tx)?; if result == 0 { return Ok(CreatePostResponse { @@ -170,6 +171,8 @@ pub async fn purge_post(post_id: i32) -> Result