use flowy_dispatch::prelude::*; use crate::{ errors::WorkspaceError, event::WorkspaceEvent, services::{AppController, WorkspaceController}, }; use flowy_database::DBConnection; use crate::{entities::workspace::UserWorkspace, handlers::*}; use std::sync::Arc; pub trait WorkspaceUser: Send + Sync { fn set_cur_workspace_id(&self, id: &str) -> DispatchFuture>; fn get_cur_workspace(&self) -> DispatchFuture>; fn db_connection(&self) -> Result; } pub fn create(user: Arc) -> Module { let workspace_controller = Arc::new(WorkspaceController::new(user.clone())); let app_controller = Arc::new(AppController::new(user.clone())); Module::new() .name("Flowy-Workspace") .data(workspace_controller) .data(app_controller) .event(WorkspaceEvent::CreateWorkspace, create_workspace) .event(WorkspaceEvent::GetWorkspaceDetail, get_workspace_detail) .event(WorkspaceEvent::CreateApp, create_app) }