refactor(issues): remove comment types (inlined)
zhenyi committed
Deleted lib/issues/features/comment/types.rs lib/issues/features/comment/types.rs +0 −62
@@ -1,62 +0,0 @@
1use db::issue::comment as comment_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}
11fn fmt_ts_opt(ts: Option<OffsetDateTime>) -> Option<String> {
12 ts.map(fmt_ts)
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
16pub struct CommentView {
17 pub id: Uuid,
18 pub issue_id: Uuid,
19 pub parent_id: Option<Uuid>,
20 pub poster_id: Uuid,
21 pub content: String,
22 pub created_at: String,
23 pub updated_at: Option<String>,
24}
25
26impl From<comment_entity::Model> for CommentView {
27 fn from(m: comment_entity::Model) -> Self {
28 Self {
29 id: m.id,
30 issue_id: m.issue_id,
31 parent_id: m.parent_id,
32 poster_id: m.poster_id,
33 content: m.content,
34 created_at: fmt_ts(m.created_at),
35 updated_at: fmt_ts_opt(m.updated_at),
36 }
37 }
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
41pub struct CommentPage {
42 pub items: Vec<CommentView>,
43 pub total: i64,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
47pub struct CreateCommentOption {
48 pub content: String,
49 pub parent_id: Option<Uuid>,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
53pub struct UpdateCommentOption {
54 pub content: String,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
58pub struct ListCommentQuery {
59 pub parent_id: Option<Uuid>,
60 pub limit: Option<u64>,
61 pub offset: Option<u64>,
62}
No newline at end of file