mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-27 18:27:39 +00:00
68 lines
1.7 KiB
Rust
68 lines
1.7 KiB
Rust
![]() |
use crate::entities::{
|
||
|
app::{App, RepeatedApp},
|
||
|
view::{RepeatedView, View, ViewType},
|
||
|
workspace::Workspace,
|
||
|
};
|
||
|
use chrono::Utc;
|
||
|
|
||
|
pub fn create_default_workspace(time: chrono::DateTime<Utc>) -> Workspace {
|
||
|
let workspace_id = uuid::Uuid::new_v4();
|
||
|
let name = "Workspace".to_string();
|
||
|
let desc = "".to_string();
|
||
|
|
||
|
let apps = RepeatedApp {
|
||
|
items: vec![create_default_app(workspace_id.to_string(), time.clone())],
|
||
|
};
|
||
|
|
||
|
let workspace = Workspace {
|
||
|
id: workspace_id.to_string(),
|
||
|
name,
|
||
|
desc,
|
||
|
apps,
|
||
|
modified_time: time.timestamp(),
|
||
|
create_time: time.timestamp(),
|
||
|
};
|
||
|
|
||
|
workspace
|
||
|
}
|
||
|
|
||
|
fn create_default_app(workspace_id: String, time: chrono::DateTime<Utc>) -> App {
|
||
|
let app_id = uuid::Uuid::new_v4();
|
||
|
let name = "Getting Started".to_string();
|
||
|
let desc = "".to_string();
|
||
|
|
||
|
let views = RepeatedView {
|
||
|
items: vec![create_default_view(app_id.to_string(), time.clone())],
|
||
|
};
|
||
|
|
||
|
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();
|
||
|
let view_type = ViewType::Doc;
|
||
|
|
||
|
View {
|
||
|
id: view_id.to_string(),
|
||
|
belong_to_id: app_id,
|
||
|
name,
|
||
|
desc,
|
||
|
view_type,
|
||
|
version: 0,
|
||
|
belongings: Default::default(),
|
||
|
modified_time: time.timestamp(),
|
||
|
create_time: time.timestamp(),
|
||
|
}
|
||
|
}
|