2021-07-14 08:07:25 +08:00
|
|
|
use crate::{
|
|
|
|
entities::workspace::{CreateWorkspaceParams, CreateWorkspaceRequest, WorkspaceDetail},
|
|
|
|
errors::WorkspaceError,
|
2021-07-18 23:56:36 +08:00
|
|
|
services::{save_workspace, WorkspaceController},
|
2021-07-14 08:07:25 +08:00
|
|
|
};
|
2021-07-18 23:56:36 +08:00
|
|
|
use flowy_dispatch::prelude::{response_ok, Data, EventResponse, ModuleData, ResponseResult};
|
|
|
|
use std::{convert::TryInto, pin::Pin, 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>>,
|
|
|
|
) -> ResponseResult<WorkspaceDetail, WorkspaceError> {
|
2021-07-18 23:56:36 +08:00
|
|
|
let controller = controller.get_ref().clone();
|
2021-07-14 08:07:25 +08:00
|
|
|
let params: CreateWorkspaceParams = data.into_inner().try_into()?;
|
2021-07-18 23:56:36 +08:00
|
|
|
let detail = save_workspace(controller, params).await?;
|
2021-07-14 08:07:25 +08:00
|
|
|
response_ok(detail)
|
|
|
|
}
|