65 lines
1.7 KiB
Rust
Raw Normal View History

2022-04-11 15:27:03 +08:00
use crate::entities::app::gen_app_id;
use crate::entities::view::gen_view_id;
use crate::entities::view::ViewDataType;
2022-04-11 15:27:03 +08:00
use crate::entities::workspace::gen_workspace_id;
use crate::revision::{AppRevision, ViewRevision, WorkspaceRevision};
2021-11-08 15:58:38 +08:00
use chrono::Utc;
pub fn create_default_workspace() -> WorkspaceRevision {
2022-03-19 16:23:34 +08:00
let time = Utc::now();
2022-04-11 15:27:03 +08:00
let workspace_id = gen_workspace_id();
2021-11-08 15:58:38 +08:00
let name = "Workspace".to_string();
let desc = "".to_string();
let apps = vec![create_default_app(workspace_id.to_string(), time)];
2021-11-08 15:58:38 +08:00
WorkspaceRevision {
2022-04-11 20:58:56 +08:00
id: workspace_id,
2021-11-08 15:58:38 +08:00
name,
desc,
apps,
modified_time: time.timestamp(),
create_time: time.timestamp(),
2021-11-27 19:19:41 +08:00
}
2021-11-08 15:58:38 +08:00
}
fn create_default_app(workspace_id: String, time: chrono::DateTime<Utc>) -> AppRevision {
2022-04-11 15:27:03 +08:00
let app_id = gen_app_id();
2021-11-13 12:42:30 +08:00
let name = "⭐️ Getting started".to_string();
2021-11-08 15:58:38 +08:00
let desc = "".to_string();
let views = vec![create_default_view(app_id.to_string(), time)];
2021-11-08 15:58:38 +08:00
AppRevision {
2022-04-11 20:58:56 +08:00
id: app_id,
2021-11-08 15:58:38 +08:00
workspace_id,
name,
desc,
belongings: views,
version: 0,
modified_time: time.timestamp(),
create_time: time.timestamp(),
}
}
fn create_default_view(app_id: String, time: chrono::DateTime<Utc>) -> ViewRevision {
2022-04-11 15:27:03 +08:00
let view_id = gen_view_id();
2021-11-08 15:58:38 +08:00
let name = "Read me".to_string();
2022-03-12 09:30:13 +08:00
let data_type = ViewDataType::TextBlock;
2021-11-08 15:58:38 +08:00
ViewRevision {
2022-04-11 20:58:56 +08:00
id: view_id,
2021-11-08 15:58:38 +08:00
belong_to_id: app_id,
name,
desc: "".to_string(),
2022-02-28 22:38:53 +08:00
data_type,
2021-11-08 15:58:38 +08:00
version: 0,
belongings: vec![],
2021-11-08 15:58:38 +08:00
modified_time: time.timestamp(),
create_time: time.timestamp(),
2022-02-28 22:38:53 +08:00
ext_data: "".to_string(),
thumbnail: "".to_string(),
2022-03-01 10:25:21 +08:00
plugin_type: 0,
2021-11-08 15:58:38 +08:00
}
}