31 lines
1002 B
Rust
Raw Normal View History

2021-07-14 08:07:25 +08:00
use crate::{
entities::workspace::{
CreateWorkspaceParams,
CreateWorkspaceRequest,
UserWorkspace,
UserWorkspaceDetail,
2021-07-19 22:44:37 +08:00
Workspace,
},
2021-07-14 08:07:25 +08:00
errors::WorkspaceError,
services::WorkspaceController,
2021-07-14 08:07:25 +08:00
};
use flowy_dispatch::prelude::{response_ok, Data, ModuleData, ResponseResult};
use std::{convert::TryInto, sync::Arc};
2021-07-13 17:19:39 +08:00
2021-07-14 08:07:25 +08:00
pub async fn create_workspace(
data: Data<CreateWorkspaceRequest>,
controller: ModuleData<Arc<WorkspaceController>>,
2021-07-19 22:44:37 +08:00
) -> ResponseResult<Workspace, WorkspaceError> {
let controller = controller.get_ref().clone();
2021-07-14 08:07:25 +08:00
let params: CreateWorkspaceParams = data.into_inner().try_into()?;
let detail = controller.save_workspace(params).await?;
response_ok(detail)
}
pub async fn get_workspace_detail(
controller: ModuleData<Arc<WorkspaceController>>,
) -> ResponseResult<UserWorkspaceDetail, WorkspaceError> {
let user_workspace = controller.get_user_workspace_detail().await?;
response_ok(user_workspace)
2021-07-14 08:07:25 +08:00
}