feat(export): add project views export
zhenyi committed
Added lib/export/project/views.rs lib/export/project/views.rs +66 −0 View lib/export/project/views.rs
@@ -0,0 +1,66 @@
1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3use time::OffsetDateTime;
4use utoipa::ToSchema;
5use uuid::Uuid;
6
7#[derive(Debug, Clone, Deserialize, ToSchema)]
8pub struct CreateViewCmd {
9 pub name: String,
10 pub description: Option<String>,
11 #[serde(default = "default_filter")]
12 pub filter: Value,
13 #[serde(default = "default_sort_by")]
14 pub sort_by: String,
15 pub group_by: Option<String>,
16 #[serde(default = "default_layout")]
17 pub layout: String,
18 #[serde(default)]
19 pub is_shared: bool,
20}
21
22fn default_filter() -> Value {
23 Value::Object(Default::default())
24}
25
26fn default_sort_by() -> String {
27 "created_at".to_string()
28}
29
30fn default_layout() -> String {
31 "list".to_string()
32}
33
34#[derive(Debug, Clone, Deserialize, ToSchema)]
35pub struct UpdateViewCmd {
36 pub name: Option<String>,
37 pub description: Option<String>,
38 pub filter: Option<Value>,
39 pub sort_by: Option<String>,
40 pub group_by: Option<String>,
41 pub layout: Option<String>,
42 pub is_shared: Option<bool>,
43}
44
45#[derive(Debug, Clone, Serialize, ToSchema)]
46pub struct ViewView {
47 pub id: Uuid,
48 pub project_id: Uuid,
49 pub creator_id: Uuid,
50 pub name: String,
51 pub description: Option<String>,
52 pub filter: Value,
53 pub sort_by: String,
54 pub group_by: Option<String>,
55 pub layout: String,
56 pub is_shared: bool,
57 pub sort_order: i32,
58 pub created_at: OffsetDateTime,
59 pub updated_at: Option<OffsetDateTime>,
60}
61
62#[derive(Debug, Clone, Serialize, ToSchema)]
63pub struct ViewPage {
64 pub total: u64,
65 pub items: Vec<ViewView>,
66}
No newline at end of file