From 054d7450f7c7a2af3b5b4f475fe2ed6c68f2f0d0 Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 16 Jun 2026 12:29:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(model):=20Post=20=E6=96=B0=E5=A2=9E=20dele?= =?UTF-8?q?ted=5Fat=20=E5=AD=97=E6=AE=B5=E5=B9=B6=E7=94=A8=20try=5Fget=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=8E=B0=E6=9C=89=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/posts/helpers.rs | 2 ++ src/cache.rs | 2 ++ src/models/post.rs | 3 +++ 3 files changed, 7 insertions(+) diff --git a/src/api/posts/helpers.rs b/src/api/posts/helpers.rs index 0ef1248..23aefb0 100644 --- a/src/api/posts/helpers.rs +++ b/src/api/posts/helpers.rs @@ -50,6 +50,7 @@ pub(super) async fn row_to_post_list( published_at: row.get("published_at"), created_at: row.get("created_at"), updated_at: row.get("updated_at"), + deleted_at: row.try_get("deleted_at").ok(), tags, cover_image: row.get("cover_image"), reading_time: (word_count / 200).max(1), @@ -143,6 +144,7 @@ pub(super) async fn row_to_post_full( published_at: row.get("published_at"), created_at: row.get("created_at"), updated_at: row.get("updated_at"), + deleted_at: row.try_get("deleted_at").ok(), tags, cover_image: row.get("cover_image"), reading_time: (word_count / 200).max(1), diff --git a/src/cache.rs b/src/cache.rs index 77cd385..af4c648 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -473,6 +473,7 @@ mod tests { published_at: None, created_at: chrono::Utc::now(), updated_at: chrono::Utc::now(), + deleted_at: None, tags: vec![], cover_image: None, reading_time: 1, @@ -520,6 +521,7 @@ mod tests { published_at: None, created_at: chrono::Utc::now(), updated_at: chrono::Utc::now(), + deleted_at: None, tags: vec![], cover_image: None, reading_time: 1, diff --git a/src/models/post.rs b/src/models/post.rs index 42b0302..b72933b 100644 --- a/src/models/post.rs +++ b/src/models/post.rs @@ -61,6 +61,8 @@ pub struct Post { pub created_at: DateTime, /// 最后更新时间。 pub updated_at: DateTime, + /// 软删除时间,None 表示未删除。仅回收站查询填充。 + pub deleted_at: Option>, /// 关联标签列表。 pub tags: Vec, /// 封面图片 URL。 @@ -161,6 +163,7 @@ mod tests { published_at: None, created_at: Utc.with_ymd_and_hms(2024, 1, 15, 10, 0, 0).unwrap(), updated_at: Utc.with_ymd_and_hms(2024, 1, 15, 10, 0, 0).unwrap(), + deleted_at: None, tags: vec![], cover_image: None, reading_time: 1,