2021-07-14 08:07:25 +08:00
|
|
|
use crate::{
|
|
|
|
entities::workspace::{CreateWorkspaceParams, CreateWorkspaceRequest, WorkspaceDetail},
|
|
|
|
errors::WorkspaceError,
|
|
|
|
services::WorkspaceController,
|
|
|
|
};
|
|
|
|
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>>,
|
|
|
|
) -> ResponseResult<WorkspaceDetail, WorkspaceError> {
|
|
|
|
let params: CreateWorkspaceParams = data.into_inner().try_into()?;
|
|
|
|
let detail = controller.save_workspace(params)?;
|
|
|
|
response_ok(detail)
|
|
|
|
}
|