Skip to content
Clone

feat(export): add issues issue_content_history export

zhenyi committed
parent 28abaa1 commit bd9e5df Browse files

1 file changed

+50 −0

Added lib/export/issues/issue_content_history.rs View lib/export/issues/issue_content_history.rs
@@ -0,0 +1,50 @@
1use db::issue::issue_content_history as hist_entity;
2use serde::{Deserialize, Serialize};
3use time::OffsetDateTime;
4use time::format_description::well_known::Rfc3339;
5use utoipa::{IntoParams, ToSchema};
6use uuid::Uuid;
7
8fn fmt_ts(ts: OffsetDateTime) -> String {
9 ts.format(&Rfc3339).unwrap_or_default()
10}
11
12#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
13pub struct ContentHistoryView {
14 pub id: Uuid,
15 pub issue_id: Uuid,
16 pub poster_id: Uuid,
17 pub comment_id: Option<Uuid>,
18 pub content_before: Option<String>,
19 pub content_after: Option<String>,
20 pub edited_at: String,
21 pub created_at: String,
22}
23
24impl From<hist_entity::Model> for ContentHistoryView {
25 fn from(m: hist_entity::Model) -> Self {
26 Self {
27 id: m.id,
28 issue_id: m.issue_id,
29 poster_id: m.poster_id,
30 comment_id: m.comment_id,
31 content_before: m.content_before,
32 content_after: m.content_after,
33 edited_at: fmt_ts(m.edited_at),
34 created_at: fmt_ts(m.created_at),
35 }
36 }
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
40pub struct ContentHistoryPage {
41 pub items: Vec<ContentHistoryView>,
42 pub total: i64,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
46pub struct ListContentHistoryQuery {
47 pub comment_id: Option<Uuid>,
48 pub limit: Option<u64>,
49 pub offset: Option<u64>,
50}