mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix compile issuse
This commit is contained in:
@ -40,6 +40,9 @@ pub enum WsErrCode {
|
||||
#[display(fmt = "Workspace desc is invalid")]
|
||||
WorkspaceDescInvalid = 4,
|
||||
|
||||
#[display(fmt = "Current workspace not found")]
|
||||
CurrentWorkspaceNotFound = 5,
|
||||
|
||||
#[display(fmt = "Id of the App is invalid")]
|
||||
AppIdInvalid = 10,
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
entities::{app::RepeatedApp, workspace::*},
|
||||
errors::WorkspaceError,
|
||||
errors::{ErrorBuilder, WorkspaceError, WsErrCode},
|
||||
services::WorkspaceController,
|
||||
};
|
||||
use flowy_dispatch::prelude::{data_result, Data, DataResult, Unit};
|
||||
@ -41,12 +41,15 @@ pub async fn read_workspace(
|
||||
pub async fn open_workspace(
|
||||
data: Data<QueryWorkspaceRequest>,
|
||||
controller: Unit<Arc<WorkspaceController>>,
|
||||
) -> DataResult<RepeatedWorkspace, WorkspaceError> {
|
||||
) -> DataResult<Workspace, WorkspaceError> {
|
||||
let params: QueryWorkspaceParams = data.into_inner().try_into()?;
|
||||
|
||||
let workspaces = controller.open_workspace(params.workspace_id).await?;
|
||||
|
||||
data_result(workspaces)
|
||||
match params.workspace_id {
|
||||
None => Err(ErrorBuilder::new(WsErrCode::WorkspaceIdInvalid).build()),
|
||||
Some(workspace_id) => {
|
||||
let workspaces = controller.open_workspace(&workspace_id).await?;
|
||||
data_result(workspaces)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(name = "get_all_workspaces", skip(controller))]
|
||||
|
@ -14,8 +14,9 @@ pub trait WorkspaceDeps: WorkspaceUser + WorkspaceDatabase {}
|
||||
|
||||
pub trait WorkspaceUser: Send + Sync {
|
||||
fn user_id(&self) -> Result<String, WorkspaceError>;
|
||||
fn set_cur_workspace_id(&self, id: &str) -> DispatchFuture<Result<(), WorkspaceError>>;
|
||||
fn get_cur_workspace(&self) -> DispatchFuture<Result<CurrentWorkspace, WorkspaceError>>;
|
||||
// fn set_cur_workspace_id(&self, id: &str) -> DispatchFuture<Result<(),
|
||||
// WorkspaceError>>; fn get_cur_workspace(&self) ->
|
||||
// DispatchFuture<Result<CurrentWorkspace, WorkspaceError>>;
|
||||
}
|
||||
|
||||
pub trait WorkspaceDatabase: Send + Sync {
|
||||
|
@ -220,6 +220,7 @@ pub enum WsErrCode {
|
||||
WorkspaceIdInvalid = 2,
|
||||
AppColorStyleInvalid = 3,
|
||||
WorkspaceDescInvalid = 4,
|
||||
CurrentWorkspaceNotFound = 5,
|
||||
AppIdInvalid = 10,
|
||||
AppNameInvalid = 11,
|
||||
ViewNameInvalid = 20,
|
||||
@ -246,6 +247,7 @@ impl ::protobuf::ProtobufEnum for WsErrCode {
|
||||
2 => ::std::option::Option::Some(WsErrCode::WorkspaceIdInvalid),
|
||||
3 => ::std::option::Option::Some(WsErrCode::AppColorStyleInvalid),
|
||||
4 => ::std::option::Option::Some(WsErrCode::WorkspaceDescInvalid),
|
||||
5 => ::std::option::Option::Some(WsErrCode::CurrentWorkspaceNotFound),
|
||||
10 => ::std::option::Option::Some(WsErrCode::AppIdInvalid),
|
||||
11 => ::std::option::Option::Some(WsErrCode::AppNameInvalid),
|
||||
20 => ::std::option::Option::Some(WsErrCode::ViewNameInvalid),
|
||||
@ -269,6 +271,7 @@ impl ::protobuf::ProtobufEnum for WsErrCode {
|
||||
WsErrCode::WorkspaceIdInvalid,
|
||||
WsErrCode::AppColorStyleInvalid,
|
||||
WsErrCode::WorkspaceDescInvalid,
|
||||
WsErrCode::CurrentWorkspaceNotFound,
|
||||
WsErrCode::AppIdInvalid,
|
||||
WsErrCode::AppNameInvalid,
|
||||
WsErrCode::ViewNameInvalid,
|
||||
@ -311,59 +314,61 @@ impl ::protobuf::reflect::ProtobufValue for WsErrCode {
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0cerrors.proto\"B\n\x0eWorkspaceError\x12\x1e\n\x04code\x18\x01\x20\
|
||||
\x01(\x0e2\n.WsErrCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03\
|
||||
msg*\x86\x03\n\tWsErrCode\x12\x0b\n\x07Unknown\x10\0\x12\x18\n\x14Worksp\
|
||||
msg*\xa4\x03\n\tWsErrCode\x12\x0b\n\x07Unknown\x10\0\x12\x18\n\x14Worksp\
|
||||
aceNameInvalid\x10\x01\x12\x16\n\x12WorkspaceIdInvalid\x10\x02\x12\x18\n\
|
||||
\x14AppColorStyleInvalid\x10\x03\x12\x18\n\x14WorkspaceDescInvalid\x10\
|
||||
\x04\x12\x10\n\x0cAppIdInvalid\x10\n\x12\x12\n\x0eAppNameInvalid\x10\x0b\
|
||||
\x12\x13\n\x0fViewNameInvalid\x10\x14\x12\x18\n\x14ViewThumbnailInvalid\
|
||||
\x10\x15\x12\x11\n\rViewIdInvalid\x10\x16\x12\x13\n\x0fViewDescInvalid\
|
||||
\x10\x17\x12\x1a\n\x16DatabaseConnectionFail\x10d\x12\x1a\n\x16Workspace\
|
||||
DatabaseError\x10e\x12\x15\n\x11UserInternalError\x10f\x12\x13\n\x0fUser\
|
||||
NotLoginYet\x10g\x12\x10\n\x0bServerError\x10\xe8\x07\x12\x13\n\x0eRecor\
|
||||
dNotFound\x10\xe9\x07J\xe9\x06\n\x06\x12\x04\0\0\x18\x01\n\x08\n\x01\x0c\
|
||||
\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\
|
||||
\x01\x12\x03\x02\x08\x16\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x17\n\
|
||||
\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\r\n\x0c\n\x05\x04\0\x02\0\x01\
|
||||
\x12\x03\x03\x0e\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\x16\n\
|
||||
\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\
|
||||
\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\
|
||||
\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\
|
||||
\x04\x06\0\x18\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x0e\n\x0b\n\x04\
|
||||
\x05\0\x02\0\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\
|
||||
\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\
|
||||
\0\x02\x01\x12\x03\x08\x04\x1d\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\
|
||||
\x04\x18\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1b\x1c\n\x0b\n\x04\
|
||||
\x05\0\x02\x02\x12\x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\
|
||||
\x04\x16\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\
|
||||
\0\x02\x03\x12\x03\n\x04\x1d\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\
|
||||
\x18\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x1b\x1c\n\x0b\n\x04\x05\0\
|
||||
\x02\x04\x12\x03\x0b\x04\x1d\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\
|
||||
\x04\x18\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x1b\x1c\n\x0b\n\x04\
|
||||
\x05\0\x02\x05\x12\x03\x0c\x04\x16\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\
|
||||
\x0c\x04\x10\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c\x13\x15\n\x0b\n\
|
||||
\x04\x05\0\x02\x06\x12\x03\r\x04\x18\n\x0c\n\x05\x05\0\x02\x06\x01\x12\
|
||||
\x03\r\x04\x12\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\r\x15\x17\n\x0b\n\
|
||||
\x04\x05\0\x02\x07\x12\x03\x0e\x04\x19\n\x0c\n\x05\x05\0\x02\x07\x01\x12\
|
||||
\x03\x0e\x04\x13\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x16\x18\n\x0b\
|
||||
\n\x04\x05\0\x02\x08\x12\x03\x0f\x04\x1e\n\x0c\n\x05\x05\0\x02\x08\x01\
|
||||
\x12\x03\x0f\x04\x18\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1b\x1d\n\
|
||||
\x0b\n\x04\x05\0\x02\t\x12\x03\x10\x04\x17\n\x0c\n\x05\x05\0\x02\t\x01\
|
||||
\x12\x03\x10\x04\x11\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x10\x14\x16\n\
|
||||
\x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04\x19\n\x0c\n\x05\x05\0\x02\n\x01\
|
||||
\x12\x03\x11\x04\x13\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x16\x18\n\
|
||||
\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04!\n\x0c\n\x05\x05\0\x02\x0b\x01\
|
||||
\x12\x03\x12\x04\x1a\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x1d\x20\n\
|
||||
\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\x04!\n\x0c\n\x05\x05\0\x02\x0c\x01\
|
||||
\x12\x03\x13\x04\x1a\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\x1d\x20\n\
|
||||
\x0b\n\x04\x05\0\x02\r\x12\x03\x14\x04\x1c\n\x0c\n\x05\x05\0\x02\r\x01\
|
||||
\x12\x03\x14\x04\x15\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\x18\x1b\n\
|
||||
\x0b\n\x04\x05\0\x02\x0e\x12\x03\x15\x04\x1a\n\x0c\n\x05\x05\0\x02\x0e\
|
||||
\x01\x12\x03\x15\x04\x13\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\x15\x16\
|
||||
\x19\n\x0b\n\x04\x05\0\x02\x0f\x12\x03\x16\x04\x17\n\x0c\n\x05\x05\0\x02\
|
||||
\x0f\x01\x12\x03\x16\x04\x0f\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\x16\
|
||||
\x12\x16\n\x0b\n\x04\x05\0\x02\x10\x12\x03\x17\x04\x1a\n\x0c\n\x05\x05\0\
|
||||
\x02\x10\x01\x12\x03\x17\x04\x12\n\x0c\n\x05\x05\0\x02\x10\x02\x12\x03\
|
||||
\x17\x15\x19b\x06proto3\
|
||||
\x04\x12\x1c\n\x18CurrentWorkspaceNotFound\x10\x05\x12\x10\n\x0cAppIdInv\
|
||||
alid\x10\n\x12\x12\n\x0eAppNameInvalid\x10\x0b\x12\x13\n\x0fViewNameInva\
|
||||
lid\x10\x14\x12\x18\n\x14ViewThumbnailInvalid\x10\x15\x12\x11\n\rViewIdI\
|
||||
nvalid\x10\x16\x12\x13\n\x0fViewDescInvalid\x10\x17\x12\x1a\n\x16Databas\
|
||||
eConnectionFail\x10d\x12\x1a\n\x16WorkspaceDatabaseError\x10e\x12\x15\n\
|
||||
\x11UserInternalError\x10f\x12\x13\n\x0fUserNotLoginYet\x10g\x12\x10\n\
|
||||
\x0bServerError\x10\xe8\x07\x12\x13\n\x0eRecordNotFound\x10\xe9\x07J\x92\
|
||||
\x07\n\x06\x12\x04\0\0\x19\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\
|
||||
\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x16\n\
|
||||
\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x17\n\x0c\n\x05\x04\0\x02\0\x06\
|
||||
\x12\x03\x03\x04\r\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0e\x12\n\x0c\
|
||||
\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\x16\n\x0b\n\x04\x04\0\x02\x01\x12\
|
||||
\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\
|
||||
\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\
|
||||
\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x19\x01\n\n\n\x03\x05\
|
||||
\0\x01\x12\x03\x06\x05\x0e\n\x0b\n\x04\x05\0\x02\0\x12\x03\x07\x04\x10\n\
|
||||
\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\x05\0\x02\0\
|
||||
\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x08\x04\x1d\n\
|
||||
\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x18\n\x0c\n\x05\x05\0\x02\
|
||||
\x01\x02\x12\x03\x08\x1b\x1c\n\x0b\n\x04\x05\0\x02\x02\x12\x03\t\x04\x1b\
|
||||
\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x16\n\x0c\n\x05\x05\0\x02\
|
||||
\x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\0\x02\x03\x12\x03\n\x04\x1d\n\
|
||||
\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x18\n\x0c\n\x05\x05\0\x02\x03\
|
||||
\x02\x12\x03\n\x1b\x1c\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x0b\x04\x1d\n\
|
||||
\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x18\n\x0c\n\x05\x05\0\x02\
|
||||
\x04\x02\x12\x03\x0b\x1b\x1c\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x0c\x04!\
|
||||
\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x1c\n\x0c\n\x05\x05\0\x02\
|
||||
\x05\x02\x12\x03\x0c\x1f\x20\n\x0b\n\x04\x05\0\x02\x06\x12\x03\r\x04\x16\
|
||||
\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x10\n\x0c\n\x05\x05\0\x02\
|
||||
\x06\x02\x12\x03\r\x13\x15\n\x0b\n\x04\x05\0\x02\x07\x12\x03\x0e\x04\x18\
|
||||
\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x12\n\x0c\n\x05\x05\0\x02\
|
||||
\x07\x02\x12\x03\x0e\x15\x17\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0f\x04\
|
||||
\x19\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x13\n\x0c\n\x05\x05\0\
|
||||
\x02\x08\x02\x12\x03\x0f\x16\x18\n\x0b\n\x04\x05\0\x02\t\x12\x03\x10\x04\
|
||||
\x1e\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x10\x04\x18\n\x0c\n\x05\x05\0\
|
||||
\x02\t\x02\x12\x03\x10\x1b\x1d\n\x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04\
|
||||
\x17\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\x11\n\x0c\n\x05\x05\0\
|
||||
\x02\n\x02\x12\x03\x11\x14\x16\n\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\
|
||||
\x19\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\x12\x04\x13\n\x0c\n\x05\x05\0\
|
||||
\x02\x0b\x02\x12\x03\x12\x16\x18\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\
|
||||
\x04!\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\x13\x04\x1a\n\x0c\n\x05\x05\
|
||||
\0\x02\x0c\x02\x12\x03\x13\x1d\x20\n\x0b\n\x04\x05\0\x02\r\x12\x03\x14\
|
||||
\x04!\n\x0c\n\x05\x05\0\x02\r\x01\x12\x03\x14\x04\x1a\n\x0c\n\x05\x05\0\
|
||||
\x02\r\x02\x12\x03\x14\x1d\x20\n\x0b\n\x04\x05\0\x02\x0e\x12\x03\x15\x04\
|
||||
\x1c\n\x0c\n\x05\x05\0\x02\x0e\x01\x12\x03\x15\x04\x15\n\x0c\n\x05\x05\0\
|
||||
\x02\x0e\x02\x12\x03\x15\x18\x1b\n\x0b\n\x04\x05\0\x02\x0f\x12\x03\x16\
|
||||
\x04\x1a\n\x0c\n\x05\x05\0\x02\x0f\x01\x12\x03\x16\x04\x13\n\x0c\n\x05\
|
||||
\x05\0\x02\x0f\x02\x12\x03\x16\x16\x19\n\x0b\n\x04\x05\0\x02\x10\x12\x03\
|
||||
\x17\x04\x17\n\x0c\n\x05\x05\0\x02\x10\x01\x12\x03\x17\x04\x0f\n\x0c\n\
|
||||
\x05\x05\0\x02\x10\x02\x12\x03\x17\x12\x16\n\x0b\n\x04\x05\0\x02\x11\x12\
|
||||
\x03\x18\x04\x1a\n\x0c\n\x05\x05\0\x02\x11\x01\x12\x03\x18\x04\x12\n\x0c\
|
||||
\n\x05\x05\0\x02\x11\x02\x12\x03\x18\x15\x19b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -30,6 +30,7 @@ pub enum WorkspaceEvent {
|
||||
ReadWorkspace = 2,
|
||||
DeleteWorkspace = 3,
|
||||
ReadAllWorkspace = 4,
|
||||
OpenWorkspace = 5,
|
||||
CreateApp = 101,
|
||||
DeleteApp = 102,
|
||||
ReadApp = 103,
|
||||
@ -52,6 +53,7 @@ impl ::protobuf::ProtobufEnum for WorkspaceEvent {
|
||||
2 => ::std::option::Option::Some(WorkspaceEvent::ReadWorkspace),
|
||||
3 => ::std::option::Option::Some(WorkspaceEvent::DeleteWorkspace),
|
||||
4 => ::std::option::Option::Some(WorkspaceEvent::ReadAllWorkspace),
|
||||
5 => ::std::option::Option::Some(WorkspaceEvent::OpenWorkspace),
|
||||
101 => ::std::option::Option::Some(WorkspaceEvent::CreateApp),
|
||||
102 => ::std::option::Option::Some(WorkspaceEvent::DeleteApp),
|
||||
103 => ::std::option::Option::Some(WorkspaceEvent::ReadApp),
|
||||
@ -71,6 +73,7 @@ impl ::protobuf::ProtobufEnum for WorkspaceEvent {
|
||||
WorkspaceEvent::ReadWorkspace,
|
||||
WorkspaceEvent::DeleteWorkspace,
|
||||
WorkspaceEvent::ReadAllWorkspace,
|
||||
WorkspaceEvent::OpenWorkspace,
|
||||
WorkspaceEvent::CreateApp,
|
||||
WorkspaceEvent::DeleteApp,
|
||||
WorkspaceEvent::ReadApp,
|
||||
@ -107,41 +110,44 @@ impl ::protobuf::reflect::ProtobufValue for WorkspaceEvent {
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0bevent.proto*\xf5\x01\n\x0eWorkspaceEvent\x12\x13\n\x0fCreateWorksp\
|
||||
\n\x0bevent.proto*\x88\x02\n\x0eWorkspaceEvent\x12\x13\n\x0fCreateWorksp\
|
||||
ace\x10\0\x12\x14\n\x10ReadCurWorkspace\x10\x01\x12\x11\n\rReadWorkspace\
|
||||
\x10\x02\x12\x13\n\x0fDeleteWorkspace\x10\x03\x12\x14\n\x10ReadAllWorksp\
|
||||
ace\x10\x04\x12\r\n\tCreateApp\x10e\x12\r\n\tDeleteApp\x10f\x12\x0b\n\
|
||||
\x07ReadApp\x10g\x12\r\n\tUpdateApp\x10h\x12\x0f\n\nCreateView\x10\xc9\
|
||||
\x01\x12\r\n\x08ReadView\x10\xca\x01\x12\x0f\n\nUpdateView\x10\xcb\x01\
|
||||
\x12\x0f\n\nDeleteView\x10\xcc\x01J\xbf\x04\n\x06\x12\x04\0\0\x10\x01\n\
|
||||
\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\x10\x01\n\n\
|
||||
\n\x03\x05\0\x01\x12\x03\x02\x05\x13\n\x0b\n\x04\x05\0\x02\0\x12\x03\x03\
|
||||
\x04\x18\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\x13\n\x0c\n\x05\x05\
|
||||
\0\x02\0\x02\x12\x03\x03\x16\x17\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x04\
|
||||
\x04\x19\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\x04\x14\n\x0c\n\x05\
|
||||
\x05\0\x02\x01\x02\x12\x03\x04\x17\x18\n\x0b\n\x04\x05\0\x02\x02\x12\x03\
|
||||
\x05\x04\x16\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\x05\x04\x11\n\x0c\n\
|
||||
\x05\x05\0\x02\x02\x02\x12\x03\x05\x14\x15\n\x0b\n\x04\x05\0\x02\x03\x12\
|
||||
\x03\x06\x04\x18\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\x06\x04\x13\n\x0c\
|
||||
\n\x05\x05\0\x02\x03\x02\x12\x03\x06\x16\x17\n\x0b\n\x04\x05\0\x02\x04\
|
||||
\x12\x03\x07\x04\x19\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x07\x04\x14\n\
|
||||
\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x07\x17\x18\n\x0b\n\x04\x05\0\x02\
|
||||
\x05\x12\x03\x08\x04\x14\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x08\x04\r\
|
||||
\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x08\x10\x13\n\x0b\n\x04\x05\0\x02\
|
||||
\x06\x12\x03\t\x04\x14\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\t\x04\r\n\
|
||||
\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\t\x10\x13\n\x0b\n\x04\x05\0\x02\x07\
|
||||
\x12\x03\n\x04\x12\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\n\x04\x0b\n\x0c\
|
||||
\n\x05\x05\0\x02\x07\x02\x12\x03\n\x0e\x11\n\x0b\n\x04\x05\0\x02\x08\x12\
|
||||
\x03\x0b\x04\x14\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0b\x04\r\n\x0c\n\
|
||||
\x05\x05\0\x02\x08\x02\x12\x03\x0b\x10\x13\n\x0b\n\x04\x05\0\x02\t\x12\
|
||||
\x03\x0c\x04\x15\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x0c\x04\x0e\n\x0c\n\
|
||||
\x05\x05\0\x02\t\x02\x12\x03\x0c\x11\x14\n\x0b\n\x04\x05\0\x02\n\x12\x03\
|
||||
\r\x04\x13\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\r\x04\x0c\n\x0c\n\x05\x05\
|
||||
\0\x02\n\x02\x12\x03\r\x0f\x12\n\x0b\n\x04\x05\0\x02\x0b\x12\x03\x0e\x04\
|
||||
\x15\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\x0e\x04\x0e\n\x0c\n\x05\x05\0\
|
||||
\x02\x0b\x02\x12\x03\x0e\x11\x14\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x0f\
|
||||
\x04\x15\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\x0f\x04\x0e\n\x0c\n\x05\
|
||||
\x05\0\x02\x0c\x02\x12\x03\x0f\x11\x14b\x06proto3\
|
||||
ace\x10\x04\x12\x11\n\rOpenWorkspace\x10\x05\x12\r\n\tCreateApp\x10e\x12\
|
||||
\r\n\tDeleteApp\x10f\x12\x0b\n\x07ReadApp\x10g\x12\r\n\tUpdateApp\x10h\
|
||||
\x12\x0f\n\nCreateView\x10\xc9\x01\x12\r\n\x08ReadView\x10\xca\x01\x12\
|
||||
\x0f\n\nUpdateView\x10\xcb\x01\x12\x0f\n\nDeleteView\x10\xcc\x01J\xe8\
|
||||
\x04\n\x06\x12\x04\0\0\x11\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\
|
||||
\x05\0\x12\x04\x02\0\x11\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x13\n\
|
||||
\x0b\n\x04\x05\0\x02\0\x12\x03\x03\x04\x18\n\x0c\n\x05\x05\0\x02\0\x01\
|
||||
\x12\x03\x03\x04\x13\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x16\x17\n\
|
||||
\x0b\n\x04\x05\0\x02\x01\x12\x03\x04\x04\x19\n\x0c\n\x05\x05\0\x02\x01\
|
||||
\x01\x12\x03\x04\x04\x14\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x04\x17\
|
||||
\x18\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x05\x04\x16\n\x0c\n\x05\x05\0\x02\
|
||||
\x02\x01\x12\x03\x05\x04\x11\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x05\
|
||||
\x14\x15\n\x0b\n\x04\x05\0\x02\x03\x12\x03\x06\x04\x18\n\x0c\n\x05\x05\0\
|
||||
\x02\x03\x01\x12\x03\x06\x04\x13\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\
|
||||
\x06\x16\x17\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x07\x04\x19\n\x0c\n\x05\
|
||||
\x05\0\x02\x04\x01\x12\x03\x07\x04\x14\n\x0c\n\x05\x05\0\x02\x04\x02\x12\
|
||||
\x03\x07\x17\x18\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x08\x04\x16\n\x0c\n\
|
||||
\x05\x05\0\x02\x05\x01\x12\x03\x08\x04\x11\n\x0c\n\x05\x05\0\x02\x05\x02\
|
||||
\x12\x03\x08\x14\x15\n\x0b\n\x04\x05\0\x02\x06\x12\x03\t\x04\x14\n\x0c\n\
|
||||
\x05\x05\0\x02\x06\x01\x12\x03\t\x04\r\n\x0c\n\x05\x05\0\x02\x06\x02\x12\
|
||||
\x03\t\x10\x13\n\x0b\n\x04\x05\0\x02\x07\x12\x03\n\x04\x14\n\x0c\n\x05\
|
||||
\x05\0\x02\x07\x01\x12\x03\n\x04\r\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\
|
||||
\n\x10\x13\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0b\x04\x12\n\x0c\n\x05\x05\
|
||||
\0\x02\x08\x01\x12\x03\x0b\x04\x0b\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\
|
||||
\x0b\x0e\x11\n\x0b\n\x04\x05\0\x02\t\x12\x03\x0c\x04\x14\n\x0c\n\x05\x05\
|
||||
\0\x02\t\x01\x12\x03\x0c\x04\r\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x0c\
|
||||
\x10\x13\n\x0b\n\x04\x05\0\x02\n\x12\x03\r\x04\x15\n\x0c\n\x05\x05\0\x02\
|
||||
\n\x01\x12\x03\r\x04\x0e\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\r\x11\x14\n\
|
||||
\x0b\n\x04\x05\0\x02\x0b\x12\x03\x0e\x04\x13\n\x0c\n\x05\x05\0\x02\x0b\
|
||||
\x01\x12\x03\x0e\x04\x0c\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x0e\x0f\
|
||||
\x12\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x0f\x04\x15\n\x0c\n\x05\x05\0\x02\
|
||||
\x0c\x01\x12\x03\x0f\x04\x0e\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x0f\
|
||||
\x11\x14\n\x0b\n\x04\x05\0\x02\r\x12\x03\x10\x04\x15\n\x0c\n\x05\x05\0\
|
||||
\x02\r\x01\x12\x03\x10\x04\x0e\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x10\
|
||||
\x11\x14b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -10,6 +10,7 @@ enum WsErrCode {
|
||||
WorkspaceIdInvalid = 2;
|
||||
AppColorStyleInvalid = 3;
|
||||
WorkspaceDescInvalid = 4;
|
||||
CurrentWorkspaceNotFound = 5;
|
||||
AppIdInvalid = 10;
|
||||
AppNameInvalid = 11;
|
||||
ViewNameInvalid = 20;
|
||||
|
@ -6,6 +6,7 @@ enum WorkspaceEvent {
|
||||
ReadWorkspace = 2;
|
||||
DeleteWorkspace = 3;
|
||||
ReadAllWorkspace = 4;
|
||||
OpenWorkspace = 5;
|
||||
CreateApp = 101;
|
||||
DeleteApp = 102;
|
||||
ReadApp = 103;
|
||||
|
@ -7,6 +7,7 @@ use crate::{
|
||||
sql_tables::workspace::{WorkspaceSql, WorkspaceTable, WorkspaceTableChangeset},
|
||||
};
|
||||
use flowy_dispatch::prelude::DispatchFuture;
|
||||
use flowy_infra::kv::KVStore;
|
||||
use flowy_net::request::HttpRequestBuilder;
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -62,12 +63,55 @@ impl WorkspaceController {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn read_cur_workspace(&self) -> Result<Workspace, WorkspaceError> {
|
||||
let user_workspace = self.user.get_cur_workspace().await?;
|
||||
let mut repeated_workspace = self
|
||||
.read_workspaces(Some(user_workspace.workspace_id.clone()))
|
||||
pub async fn open_workspace(&self, workspace_id: &str) -> Result<Workspace, WorkspaceError> {
|
||||
let user_id = self.user.user_id()?;
|
||||
let result = self
|
||||
.read_workspace_table(Some(workspace_id.to_owned()), user_id)
|
||||
.await?;
|
||||
|
||||
match result.first() {
|
||||
None => Err(ErrorBuilder::new(WsErrCode::RecordNotFound).build()),
|
||||
Some(workspace_table) => {
|
||||
let workspace: Workspace = workspace_table.clone().into();
|
||||
set_current_workspace(&workspace.id);
|
||||
Ok(workspace)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn read_workspaces(
|
||||
&self,
|
||||
workspace_id: Option<String>,
|
||||
) -> Result<RepeatedWorkspace, WorkspaceError> {
|
||||
let user_id = self.user.user_id()?;
|
||||
let workspace_tables = self.read_workspace_table(workspace_id, user_id).await?;
|
||||
let mut workspaces = vec![];
|
||||
for table in workspace_tables {
|
||||
let apps = self.read_apps(&table.id).await?;
|
||||
let mut workspace: Workspace = table.into();
|
||||
workspace.apps.items = apps;
|
||||
|
||||
workspaces.push(workspace);
|
||||
}
|
||||
Ok(RepeatedWorkspace { items: workspaces })
|
||||
}
|
||||
|
||||
pub async fn read_workspaces_belong_to_user(&self) -> Result<Vec<Workspace>, WorkspaceError> {
|
||||
let user_id = self.user.user_id()?;
|
||||
let workspace = self
|
||||
.sql
|
||||
.read_workspaces_belong_to_user(&user_id)?
|
||||
.into_iter()
|
||||
.map(|workspace_table| workspace_table.into())
|
||||
.collect::<Vec<Workspace>>();
|
||||
|
||||
Ok(workspace)
|
||||
}
|
||||
|
||||
pub async fn read_cur_workspace(&self) -> Result<Workspace, WorkspaceError> {
|
||||
let workspace_id = get_current_workspace()?;
|
||||
let mut repeated_workspace = self.read_workspaces(Some(workspace_id.clone())).await?;
|
||||
|
||||
if repeated_workspace.is_empty() {
|
||||
return Err(ErrorBuilder::new(WsErrCode::RecordNotFound).build());
|
||||
}
|
||||
@ -82,50 +126,11 @@ impl WorkspaceController {
|
||||
}
|
||||
|
||||
pub async fn read_cur_apps(&self) -> Result<Vec<App>, WorkspaceError> {
|
||||
let user_workspace = self.user.get_cur_workspace().await?;
|
||||
let apps = self.read_apps(&user_workspace.workspace_id).await?;
|
||||
let workspace_id = get_current_workspace()?;
|
||||
let apps = self.read_apps(&workspace_id).await?;
|
||||
Ok(apps)
|
||||
}
|
||||
|
||||
pub async fn open_workspace(&self, workspace_id: &str) -> Result<Workspace, WorkspaceError> {
|
||||
let user_id = self.user.user_id()?;
|
||||
let result = self
|
||||
.read_workspace_table(Some(workspace_id.to_owned()), user_id)
|
||||
.await?
|
||||
.first();
|
||||
|
||||
match result {
|
||||
None => Err(ErrorBuilder::new(WsErrCode::RecordNotFound).build()),
|
||||
Some(workspace_table) => {
|
||||
let workspace: Workspace = workspace_table.into();
|
||||
Ok(workspace)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn read_workspaces(
|
||||
&self,
|
||||
workspace_id: Option<String>,
|
||||
) -> Result<RepeatedWorkspace, WorkspaceError> {
|
||||
let user_id = self.user.user_id()?;
|
||||
let workspace_tables = self.read_workspace_table(workspace_id, user_id).await?;
|
||||
let mut workspaces = vec![];
|
||||
|
||||
Ok(RepeatedWorkspace { items: workspaces })
|
||||
}
|
||||
|
||||
pub async fn read_workspaces_belong_to_user(&self) -> Result<Vec<Workspace>, WorkspaceError> {
|
||||
let user_id = self.user.user_id()?;
|
||||
let workspace = self
|
||||
.sql
|
||||
.read_workspaces_belong_to_user(&user_id)?
|
||||
.into_iter()
|
||||
.map(|workspace_table| workspace_table.into())
|
||||
.collect::<Vec<Workspace>>();
|
||||
|
||||
Ok(workspace)
|
||||
}
|
||||
|
||||
pub async fn read_apps(&self, workspace_id: &str) -> Result<Vec<App>, WorkspaceError> {
|
||||
let apps = self
|
||||
.sql
|
||||
@ -154,6 +159,19 @@ impl WorkspaceController {
|
||||
}
|
||||
}
|
||||
|
||||
const CURRENT_WORKSPACE_ID: &str = "current_workspace_id";
|
||||
|
||||
fn set_current_workspace(workspace: &str) {
|
||||
KVStore::set_str(CURRENT_WORKSPACE_ID, workspace.to_owned());
|
||||
}
|
||||
|
||||
fn get_current_workspace() -> Result<String, WorkspaceError> {
|
||||
match KVStore::get_str(CURRENT_WORKSPACE_ID) {
|
||||
None => Err(ErrorBuilder::new(WsErrCode::CurrentWorkspaceNotFound).build()),
|
||||
Some(workspace_id) => Ok(workspace_id),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn create_workspace_request(
|
||||
params: CreateWorkspaceParams,
|
||||
url: &str,
|
||||
|
@ -30,13 +30,11 @@ impl WorkspaceSql {
|
||||
user_id: &str,
|
||||
) -> Result<Vec<WorkspaceTable>, WorkspaceError> {
|
||||
let mut filter = dsl::workspace_table.filter(workspace_table::user_id.eq(user_id));
|
||||
|
||||
if let Some(workspace_id) = workspace_id {
|
||||
filter.filter(workspace_table::id.eq(&workspace_id));
|
||||
}
|
||||
|
||||
let workspaces = filter.load::<WorkspaceTable>(&*(self.database.db_connection()?))?;
|
||||
|
||||
Ok(workspaces)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user