70 lines
1.7 KiB
Rust
Raw Normal View History

2021-11-08 15:58:38 +08:00
use crate::entities::{
app::{App, RepeatedApp},
2022-02-28 22:38:53 +08:00
view::{RepeatedView, View, ViewDataType},
2021-11-08 15:58:38 +08:00
workspace::Workspace,
};
use chrono::Utc;
2022-03-19 16:23:34 +08:00
pub fn create_default_workspace() -> Workspace {
let time = Utc::now();
2021-11-08 15:58:38 +08:00
let workspace_id = uuid::Uuid::new_v4();
let name = "Workspace".to_string();
let desc = "".to_string();
let apps = RepeatedApp {
2021-11-27 19:19:41 +08:00
items: vec![create_default_app(workspace_id.to_string(), time)],
2021-11-08 15:58:38 +08:00
};
2021-11-27 19:19:41 +08:00
Workspace {
2021-11-08 15:58:38 +08:00
id: workspace_id.to_string(),
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>) -> App {
let app_id = uuid::Uuid::new_v4();
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 = RepeatedView {
2021-11-27 19:19:41 +08:00
items: vec![create_default_view(app_id.to_string(), time)],
2021-11-08 15:58:38 +08:00
};
App {
id: app_id.to_string(),
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>) -> View {
let view_id = uuid::Uuid::new_v4();
let name = "Read me".to_string();
let desc = "".to_string();
2022-03-12 09:30:13 +08:00
let data_type = ViewDataType::TextBlock;
2021-11-08 15:58:38 +08:00
View {
id: view_id.to_string(),
belong_to_id: app_id,
name,
desc,
2022-02-28 22:38:53 +08:00
data_type,
2021-11-08 15:58:38 +08:00
version: 0,
belongings: Default::default(),
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
}
}