refactor(space): remove channels types (inlined)
zhenyi committed
Deleted lib/space/features/channels/types.rs lib/space/features/channels/types.rs +0 −61
@@ -1,61 +0,0 @@
1use db::channel::channels as channel_entity;
2use serde::{Deserialize, Serialize};
3use time::OffsetDateTime;
4use time::format_description::well_known::Rfc3339;
5use utoipa::ToSchema;
6use uuid::Uuid;
7
8fn fmt_ts(ts: OffsetDateTime) -> String {
9 ts.format(&Rfc3339).unwrap_or_default()
10}
11
12fn fmt_ts_opt(ts: Option<OffsetDateTime>) -> Option<String> {
13 ts.map(fmt_ts)
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
17pub struct ChannelView {
18 pub id: Uuid,
19 pub space_id: Option<Uuid>,
20 pub name: String,
21 pub parent_id: Option<Uuid>,
22 pub color: Option<String>,
23 pub position: i32,
24 pub icon: Option<String>,
25 pub topic: Option<String>,
26 pub purpose: Option<String>,
27 pub is_archived: bool,
28 pub archived_at: Option<String>,
29 pub archived_by: Option<Uuid>,
30 pub created_at: String,
31 pub updated_at: String,
32 pub created_by: Uuid,
33}
34
35impl From<channel_entity::Model> for ChannelView {
36 fn from(c: channel_entity::Model) -> Self {
37 Self {
38 id: c.id,
39 space_id: c.space_id,
40 name: c.name,
41 parent_id: c.parent_id,
42 color: c.color,
43 position: c.position,
44 icon: c.icon,
45 topic: c.topic,
46 purpose: c.purpose,
47 is_archived: c.is_archived,
48 archived_at: fmt_ts_opt(c.archived_at),
49 archived_by: c.archived_by,
50 created_at: fmt_ts(c.created_at),
51 updated_at: fmt_ts(c.updated_at),
52 created_by: c.created_by,
53 }
54 }
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
58pub struct ChannelPage {
59 pub items: Vec<ChannelView>,
60 pub total: i64,
61}
No newline at end of file