fix compile issuse

This commit is contained in:
appflowy 2021-08-28 23:08:12 +08:00
parent 138998aebd
commit 876c49b904
19 changed files with 302 additions and 492 deletions

View File

@ -19,11 +19,6 @@ enum UpdateUserRequest_OneOfEmail {
notSet
}
enum UpdateUserRequest_OneOfWorkspace {
workspace,
notSet
}
enum UpdateUserRequest_OneOfPassword {
password,
notSet
@ -38,24 +33,18 @@ class UpdateUserRequest extends $pb.GeneratedMessage {
3 : UpdateUserRequest_OneOfEmail.email,
0 : UpdateUserRequest_OneOfEmail.notSet
};
static const $core.Map<$core.int, UpdateUserRequest_OneOfWorkspace> _UpdateUserRequest_OneOfWorkspaceByTag = {
4 : UpdateUserRequest_OneOfWorkspace.workspace,
0 : UpdateUserRequest_OneOfWorkspace.notSet
};
static const $core.Map<$core.int, UpdateUserRequest_OneOfPassword> _UpdateUserRequest_OneOfPasswordByTag = {
5 : UpdateUserRequest_OneOfPassword.password,
4 : UpdateUserRequest_OneOfPassword.password,
0 : UpdateUserRequest_OneOfPassword.notSet
};
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UpdateUserRequest', createEmptyInstance: create)
..oo(0, [2])
..oo(1, [3])
..oo(2, [4])
..oo(3, [5])
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'workspace')
..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..hasRequiredFields = false
;
@ -64,7 +53,6 @@ class UpdateUserRequest extends $pb.GeneratedMessage {
$core.String? id,
$core.String? name,
$core.String? email,
$core.String? workspace,
$core.String? password,
}) {
final _result = create();
@ -77,9 +65,6 @@ class UpdateUserRequest extends $pb.GeneratedMessage {
if (email != null) {
_result.email = email;
}
if (workspace != null) {
_result.workspace = workspace;
}
if (password != null) {
_result.password = password;
}
@ -112,11 +97,8 @@ class UpdateUserRequest extends $pb.GeneratedMessage {
UpdateUserRequest_OneOfEmail whichOneOfEmail() => _UpdateUserRequest_OneOfEmailByTag[$_whichOneof(1)]!;
void clearOneOfEmail() => clearField($_whichOneof(1));
UpdateUserRequest_OneOfWorkspace whichOneOfWorkspace() => _UpdateUserRequest_OneOfWorkspaceByTag[$_whichOneof(2)]!;
void clearOneOfWorkspace() => clearField($_whichOneof(2));
UpdateUserRequest_OneOfPassword whichOneOfPassword() => _UpdateUserRequest_OneOfPasswordByTag[$_whichOneof(3)]!;
void clearOneOfPassword() => clearField($_whichOneof(3));
UpdateUserRequest_OneOfPassword whichOneOfPassword() => _UpdateUserRequest_OneOfPasswordByTag[$_whichOneof(2)]!;
void clearOneOfPassword() => clearField($_whichOneof(2));
@$pb.TagNumber(1)
$core.String get id => $_getSZ(0);
@ -146,22 +128,13 @@ class UpdateUserRequest extends $pb.GeneratedMessage {
void clearEmail() => clearField(3);
@$pb.TagNumber(4)
$core.String get workspace => $_getSZ(3);
$core.String get password => $_getSZ(3);
@$pb.TagNumber(4)
set workspace($core.String v) { $_setString(3, v); }
set password($core.String v) { $_setString(3, v); }
@$pb.TagNumber(4)
$core.bool hasWorkspace() => $_has(3);
$core.bool hasPassword() => $_has(3);
@$pb.TagNumber(4)
void clearWorkspace() => clearField(4);
@$pb.TagNumber(5)
$core.String get password => $_getSZ(4);
@$pb.TagNumber(5)
set password($core.String v) { $_setString(4, v); }
@$pb.TagNumber(5)
$core.bool hasPassword() => $_has(4);
@$pb.TagNumber(5)
void clearPassword() => clearField(5);
void clearPassword() => clearField(4);
}
enum UpdateUserParams_OneOfName {
@ -174,11 +147,6 @@ enum UpdateUserParams_OneOfEmail {
notSet
}
enum UpdateUserParams_OneOfWorkspace {
workspace,
notSet
}
enum UpdateUserParams_OneOfPassword {
password,
notSet
@ -193,24 +161,18 @@ class UpdateUserParams extends $pb.GeneratedMessage {
3 : UpdateUserParams_OneOfEmail.email,
0 : UpdateUserParams_OneOfEmail.notSet
};
static const $core.Map<$core.int, UpdateUserParams_OneOfWorkspace> _UpdateUserParams_OneOfWorkspaceByTag = {
4 : UpdateUserParams_OneOfWorkspace.workspace,
0 : UpdateUserParams_OneOfWorkspace.notSet
};
static const $core.Map<$core.int, UpdateUserParams_OneOfPassword> _UpdateUserParams_OneOfPasswordByTag = {
5 : UpdateUserParams_OneOfPassword.password,
4 : UpdateUserParams_OneOfPassword.password,
0 : UpdateUserParams_OneOfPassword.notSet
};
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UpdateUserParams', createEmptyInstance: create)
..oo(0, [2])
..oo(1, [3])
..oo(2, [4])
..oo(3, [5])
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'workspace')
..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..hasRequiredFields = false
;
@ -219,7 +181,6 @@ class UpdateUserParams extends $pb.GeneratedMessage {
$core.String? id,
$core.String? name,
$core.String? email,
$core.String? workspace,
$core.String? password,
}) {
final _result = create();
@ -232,9 +193,6 @@ class UpdateUserParams extends $pb.GeneratedMessage {
if (email != null) {
_result.email = email;
}
if (workspace != null) {
_result.workspace = workspace;
}
if (password != null) {
_result.password = password;
}
@ -267,11 +225,8 @@ class UpdateUserParams extends $pb.GeneratedMessage {
UpdateUserParams_OneOfEmail whichOneOfEmail() => _UpdateUserParams_OneOfEmailByTag[$_whichOneof(1)]!;
void clearOneOfEmail() => clearField($_whichOneof(1));
UpdateUserParams_OneOfWorkspace whichOneOfWorkspace() => _UpdateUserParams_OneOfWorkspaceByTag[$_whichOneof(2)]!;
void clearOneOfWorkspace() => clearField($_whichOneof(2));
UpdateUserParams_OneOfPassword whichOneOfPassword() => _UpdateUserParams_OneOfPasswordByTag[$_whichOneof(3)]!;
void clearOneOfPassword() => clearField($_whichOneof(3));
UpdateUserParams_OneOfPassword whichOneOfPassword() => _UpdateUserParams_OneOfPasswordByTag[$_whichOneof(2)]!;
void clearOneOfPassword() => clearField($_whichOneof(2));
@$pb.TagNumber(1)
$core.String get id => $_getSZ(0);
@ -301,21 +256,12 @@ class UpdateUserParams extends $pb.GeneratedMessage {
void clearEmail() => clearField(3);
@$pb.TagNumber(4)
$core.String get workspace => $_getSZ(3);
$core.String get password => $_getSZ(3);
@$pb.TagNumber(4)
set workspace($core.String v) { $_setString(3, v); }
set password($core.String v) { $_setString(3, v); }
@$pb.TagNumber(4)
$core.bool hasWorkspace() => $_has(3);
$core.bool hasPassword() => $_has(3);
@$pb.TagNumber(4)
void clearWorkspace() => clearField(4);
@$pb.TagNumber(5)
$core.String get password => $_getSZ(4);
@$pb.TagNumber(5)
set password($core.String v) { $_setString(4, v); }
@$pb.TagNumber(5)
$core.bool hasPassword() => $_has(4);
@$pb.TagNumber(5)
void clearPassword() => clearField(5);
void clearPassword() => clearField(4);
}

View File

@ -15,19 +15,17 @@ const UpdateUserRequest$json = const {
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '9': 0, '10': 'name'},
const {'1': 'email', '3': 3, '4': 1, '5': 9, '9': 1, '10': 'email'},
const {'1': 'workspace', '3': 4, '4': 1, '5': 9, '9': 2, '10': 'workspace'},
const {'1': 'password', '3': 5, '4': 1, '5': 9, '9': 3, '10': 'password'},
const {'1': 'password', '3': 4, '4': 1, '5': 9, '9': 2, '10': 'password'},
],
'8': const [
const {'1': 'one_of_name'},
const {'1': 'one_of_email'},
const {'1': 'one_of_workspace'},
const {'1': 'one_of_password'},
],
};
/// Descriptor for `UpdateUserRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List updateUserRequestDescriptor = $convert.base64Decode('ChFVcGRhdGVVc2VyUmVxdWVzdBIOCgJpZBgBIAEoCVICaWQSFAoEbmFtZRgCIAEoCUgAUgRuYW1lEhYKBWVtYWlsGAMgASgJSAFSBWVtYWlsEh4KCXdvcmtzcGFjZRgEIAEoCUgCUgl3b3Jrc3BhY2USHAoIcGFzc3dvcmQYBSABKAlIA1IIcGFzc3dvcmRCDQoLb25lX29mX25hbWVCDgoMb25lX29mX2VtYWlsQhIKEG9uZV9vZl93b3Jrc3BhY2VCEQoPb25lX29mX3Bhc3N3b3Jk');
final $typed_data.Uint8List updateUserRequestDescriptor = $convert.base64Decode('ChFVcGRhdGVVc2VyUmVxdWVzdBIOCgJpZBgBIAEoCVICaWQSFAoEbmFtZRgCIAEoCUgAUgRuYW1lEhYKBWVtYWlsGAMgASgJSAFSBWVtYWlsEhwKCHBhc3N3b3JkGAQgASgJSAJSCHBhc3N3b3JkQg0KC29uZV9vZl9uYW1lQg4KDG9uZV9vZl9lbWFpbEIRCg9vbmVfb2ZfcGFzc3dvcmQ=');
@$core.Deprecated('Use updateUserParamsDescriptor instead')
const UpdateUserParams$json = const {
'1': 'UpdateUserParams',
@ -35,16 +33,14 @@ const UpdateUserParams$json = const {
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '9': 0, '10': 'name'},
const {'1': 'email', '3': 3, '4': 1, '5': 9, '9': 1, '10': 'email'},
const {'1': 'workspace', '3': 4, '4': 1, '5': 9, '9': 2, '10': 'workspace'},
const {'1': 'password', '3': 5, '4': 1, '5': 9, '9': 3, '10': 'password'},
const {'1': 'password', '3': 4, '4': 1, '5': 9, '9': 2, '10': 'password'},
],
'8': const [
const {'1': 'one_of_name'},
const {'1': 'one_of_email'},
const {'1': 'one_of_workspace'},
const {'1': 'one_of_password'},
],
};
/// Descriptor for `UpdateUserParams`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List updateUserParamsDescriptor = $convert.base64Decode('ChBVcGRhdGVVc2VyUGFyYW1zEg4KAmlkGAEgASgJUgJpZBIUCgRuYW1lGAIgASgJSABSBG5hbWUSFgoFZW1haWwYAyABKAlIAVIFZW1haWwSHgoJd29ya3NwYWNlGAQgASgJSAJSCXdvcmtzcGFjZRIcCghwYXNzd29yZBgFIAEoCUgDUghwYXNzd29yZEINCgtvbmVfb2ZfbmFtZUIOCgxvbmVfb2ZfZW1haWxCEgoQb25lX29mX3dvcmtzcGFjZUIRCg9vbmVfb2ZfcGFzc3dvcmQ=');
final $typed_data.Uint8List updateUserParamsDescriptor = $convert.base64Decode('ChBVcGRhdGVVc2VyUGFyYW1zEg4KAmlkGAEgASgJUgJpZBIUCgRuYW1lGAIgASgJSABSBG5hbWUSFgoFZW1haWwYAyABKAlIAVIFZW1haWwSHAoIcGFzc3dvcmQYBCABKAlIAlIIcGFzc3dvcmRCDQoLb25lX29mX25hbWVCDgoMb25lX29mX2VtYWlsQhEKD29uZV9vZl9wYXNzd29yZA==');

View File

@ -15,6 +15,7 @@ class WsErrCode extends $pb.ProtobufEnum {
static const WsErrCode WorkspaceIdInvalid = WsErrCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceIdInvalid');
static const WsErrCode AppColorStyleInvalid = WsErrCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppColorStyleInvalid');
static const WsErrCode WorkspaceDescInvalid = WsErrCode._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceDescInvalid');
static const WsErrCode CurrentWorkspaceNotFound = WsErrCode._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CurrentWorkspaceNotFound');
static const WsErrCode AppIdInvalid = WsErrCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppIdInvalid');
static const WsErrCode AppNameInvalid = WsErrCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppNameInvalid');
static const WsErrCode ViewNameInvalid = WsErrCode._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameInvalid');
@ -34,6 +35,7 @@ class WsErrCode extends $pb.ProtobufEnum {
WorkspaceIdInvalid,
AppColorStyleInvalid,
WorkspaceDescInvalid,
CurrentWorkspaceNotFound,
AppIdInvalid,
AppNameInvalid,
ViewNameInvalid,

View File

@ -17,6 +17,7 @@ const WsErrCode$json = const {
const {'1': 'WorkspaceIdInvalid', '2': 2},
const {'1': 'AppColorStyleInvalid', '2': 3},
const {'1': 'WorkspaceDescInvalid', '2': 4},
const {'1': 'CurrentWorkspaceNotFound', '2': 5},
const {'1': 'AppIdInvalid', '2': 10},
const {'1': 'AppNameInvalid', '2': 11},
const {'1': 'ViewNameInvalid', '2': 20},
@ -33,7 +34,7 @@ const WsErrCode$json = const {
};
/// Descriptor for `WsErrCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List wsErrCodeDescriptor = $convert.base64Decode('CglXc0VyckNvZGUSCwoHVW5rbm93bhAAEhgKFFdvcmtzcGFjZU5hbWVJbnZhbGlkEAESFgoSV29ya3NwYWNlSWRJbnZhbGlkEAISGAoUQXBwQ29sb3JTdHlsZUludmFsaWQQAxIYChRXb3Jrc3BhY2VEZXNjSW52YWxpZBAEEhAKDEFwcElkSW52YWxpZBAKEhIKDkFwcE5hbWVJbnZhbGlkEAsSEwoPVmlld05hbWVJbnZhbGlkEBQSGAoUVmlld1RodW1ibmFpbEludmFsaWQQFRIRCg1WaWV3SWRJbnZhbGlkEBYSEwoPVmlld0Rlc2NJbnZhbGlkEBcSGgoWRGF0YWJhc2VDb25uZWN0aW9uRmFpbBBkEhoKFldvcmtzcGFjZURhdGFiYXNlRXJyb3IQZRIVChFVc2VySW50ZXJuYWxFcnJvchBmEhMKD1VzZXJOb3RMb2dpbllldBBnEhAKC1NlcnZlckVycm9yEOgHEhMKDlJlY29yZE5vdEZvdW5kEOkH');
final $typed_data.Uint8List wsErrCodeDescriptor = $convert.base64Decode('CglXc0VyckNvZGUSCwoHVW5rbm93bhAAEhgKFFdvcmtzcGFjZU5hbWVJbnZhbGlkEAESFgoSV29ya3NwYWNlSWRJbnZhbGlkEAISGAoUQXBwQ29sb3JTdHlsZUludmFsaWQQAxIYChRXb3Jrc3BhY2VEZXNjSW52YWxpZBAEEhwKGEN1cnJlbnRXb3Jrc3BhY2VOb3RGb3VuZBAFEhAKDEFwcElkSW52YWxpZBAKEhIKDkFwcE5hbWVJbnZhbGlkEAsSEwoPVmlld05hbWVJbnZhbGlkEBQSGAoUVmlld1RodW1ibmFpbEludmFsaWQQFRIRCg1WaWV3SWRJbnZhbGlkEBYSEwoPVmlld0Rlc2NJbnZhbGlkEBcSGgoWRGF0YWJhc2VDb25uZWN0aW9uRmFpbBBkEhoKFldvcmtzcGFjZURhdGFiYXNlRXJyb3IQZRIVChFVc2VySW50ZXJuYWxFcnJvchBmEhMKD1VzZXJOb3RMb2dpbllldBBnEhAKC1NlcnZlckVycm9yEOgHEhMKDlJlY29yZE5vdEZvdW5kEOkH');
@$core.Deprecated('Use workspaceErrorDescriptor instead')
const WorkspaceError$json = const {
'1': 'WorkspaceError',

View File

@ -15,6 +15,7 @@ class WorkspaceEvent extends $pb.ProtobufEnum {
static const WorkspaceEvent ReadWorkspace = WorkspaceEvent._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadWorkspace');
static const WorkspaceEvent DeleteWorkspace = WorkspaceEvent._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DeleteWorkspace');
static const WorkspaceEvent ReadAllWorkspace = WorkspaceEvent._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadAllWorkspace');
static const WorkspaceEvent OpenWorkspace = WorkspaceEvent._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'OpenWorkspace');
static const WorkspaceEvent CreateApp = WorkspaceEvent._(101, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CreateApp');
static const WorkspaceEvent DeleteApp = WorkspaceEvent._(102, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DeleteApp');
static const WorkspaceEvent ReadApp = WorkspaceEvent._(103, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadApp');
@ -30,6 +31,7 @@ class WorkspaceEvent extends $pb.ProtobufEnum {
ReadWorkspace,
DeleteWorkspace,
ReadAllWorkspace,
OpenWorkspace,
CreateApp,
DeleteApp,
ReadApp,

View File

@ -17,6 +17,7 @@ const WorkspaceEvent$json = const {
const {'1': 'ReadWorkspace', '2': 2},
const {'1': 'DeleteWorkspace', '2': 3},
const {'1': 'ReadAllWorkspace', '2': 4},
const {'1': 'OpenWorkspace', '2': 5},
const {'1': 'CreateApp', '2': 101},
const {'1': 'DeleteApp', '2': 102},
const {'1': 'ReadApp', '2': 103},
@ -29,4 +30,4 @@ const WorkspaceEvent$json = const {
};
/// Descriptor for `WorkspaceEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List workspaceEventDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABIUChBSZWFkQ3VyV29ya3NwYWNlEAESEQoNUmVhZFdvcmtzcGFjZRACEhMKD0RlbGV0ZVdvcmtzcGFjZRADEhQKEFJlYWRBbGxXb3Jrc3BhY2UQBBINCglDcmVhdGVBcHAQZRINCglEZWxldGVBcHAQZhILCgdSZWFkQXBwEGcSDQoJVXBkYXRlQXBwEGgSDwoKQ3JlYXRlVmlldxDJARINCghSZWFkVmlldxDKARIPCgpVcGRhdGVWaWV3EMsBEg8KCkRlbGV0ZVZpZXcQzAE=');
final $typed_data.Uint8List workspaceEventDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABIUChBSZWFkQ3VyV29ya3NwYWNlEAESEQoNUmVhZFdvcmtzcGFjZRACEhMKD0RlbGV0ZVdvcmtzcGFjZRADEhQKEFJlYWRBbGxXb3Jrc3BhY2UQBBIRCg1PcGVuV29ya3NwYWNlEAUSDQoJQ3JlYXRlQXBwEGUSDQoJRGVsZXRlQXBwEGYSCwoHUmVhZEFwcBBnEg0KCVVwZGF0ZUFwcBBoEg8KCkNyZWF0ZVZpZXcQyQESDQoIUmVhZFZpZXcQygESDwoKVXBkYXRlVmlldxDLARIPCgpEZWxldGVWaWV3EMwB');

View File

@ -21,43 +21,43 @@ impl WorkspaceUser for WorkspaceUserImpl {
})
}
fn set_cur_workspace_id(
&self,
workspace_id: &str,
) -> DispatchFuture<Result<(), WorkspaceError>> {
let user_session = self.user_session.clone();
let workspace_id = workspace_id.to_owned();
DispatchFuture {
fut: Box::pin(async move {
let _ = user_session
.set_current_workspace(&workspace_id)
.await
.map_err(|e| {
ErrorBuilder::new(WsErrCode::UserInternalError)
.error(e)
.build()
})?;
Ok(())
}),
}
}
fn get_cur_workspace(&self) -> DispatchFuture<Result<CurrentWorkspace, WorkspaceError>> {
let user_session = self.user_session.clone();
DispatchFuture {
fut: Box::pin(async move {
let user_detail = user_session.user_detail().map_err(|e| {
ErrorBuilder::new(WsErrCode::UserNotLoginYet)
.error(e)
.build()
})?;
Ok(CurrentWorkspace {
workspace_id: "".to_owned(),
})
}),
}
}
// fn set_cur_workspace_id(
// &self,
// workspace_id: &str,
// ) -> DispatchFuture<Result<(), WorkspaceError>> {
// let user_session = self.user_session.clone();
// let workspace_id = workspace_id.to_owned();
// DispatchFuture {
// fut: Box::pin(async move {
// let _ = user_session
// .set_current_workspace(&workspace_id)
// .await
// .map_err(|e| {
// ErrorBuilder::new(WsErrCode::UserInternalError)
// .error(e)
// .build()
// })?;
// Ok(())
// }),
// }
// }
//
// fn get_cur_workspace(&self) -> DispatchFuture<Result<CurrentWorkspace,
// WorkspaceError>> { let user_session = self.user_session.clone();
// DispatchFuture {
// fut: Box::pin(async move {
// let user_detail = user_session.user_detail().map_err(|e| {
// ErrorBuilder::new(WsErrCode::UserNotLoginYet)
// .error(e)
// .build()
// })?;
//
// Ok(CurrentWorkspace {
// workspace_id: "".to_owned(),
// })
// }),
// }
// }
}
pub struct WorkspaceDatabaseImpl {

View File

@ -30,7 +30,6 @@ pub struct UpdateUserRequest {
// message oneof groups
pub one_of_name: ::std::option::Option<UpdateUserRequest_oneof_one_of_name>,
pub one_of_email: ::std::option::Option<UpdateUserRequest_oneof_one_of_email>,
pub one_of_workspace: ::std::option::Option<UpdateUserRequest_oneof_one_of_workspace>,
pub one_of_password: ::std::option::Option<UpdateUserRequest_oneof_one_of_password>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
@ -53,11 +52,6 @@ pub enum UpdateUserRequest_oneof_one_of_email {
email(::std::string::String),
}
#[derive(Clone,PartialEq,Debug)]
pub enum UpdateUserRequest_oneof_one_of_workspace {
workspace(::std::string::String),
}
#[derive(Clone,PartialEq,Debug)]
pub enum UpdateUserRequest_oneof_one_of_password {
password(::std::string::String),
@ -192,56 +186,7 @@ impl UpdateUserRequest {
}
}
// string workspace = 4;
pub fn get_workspace(&self) -> &str {
match self.one_of_workspace {
::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(ref v)) => v,
_ => "",
}
}
pub fn clear_workspace(&mut self) {
self.one_of_workspace = ::std::option::Option::None;
}
pub fn has_workspace(&self) -> bool {
match self.one_of_workspace {
::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(..)) => true,
_ => false,
}
}
// Param is passed by value, moved
pub fn set_workspace(&mut self, v: ::std::string::String) {
self.one_of_workspace = ::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(v))
}
// Mutable pointer to the field.
pub fn mut_workspace(&mut self) -> &mut ::std::string::String {
if let ::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(_)) = self.one_of_workspace {
} else {
self.one_of_workspace = ::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(::std::string::String::new()));
}
match self.one_of_workspace {
::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(ref mut v)) => v,
_ => panic!(),
}
}
// Take field
pub fn take_workspace(&mut self) -> ::std::string::String {
if self.has_workspace() {
match self.one_of_workspace.take() {
::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(v)) => v,
_ => panic!(),
}
} else {
::std::string::String::new()
}
}
// string password = 5;
// string password = 4;
pub fn get_password(&self) -> &str {
@ -316,12 +261,6 @@ impl ::protobuf::Message for UpdateUserRequest {
self.one_of_email = ::std::option::Option::Some(UpdateUserRequest_oneof_one_of_email::email(is.read_string()?));
},
4 => {
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
self.one_of_workspace = ::std::option::Option::Some(UpdateUserRequest_oneof_one_of_workspace::workspace(is.read_string()?));
},
5 => {
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
@ -356,17 +295,10 @@ impl ::protobuf::Message for UpdateUserRequest {
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_workspace {
match v {
&UpdateUserRequest_oneof_one_of_workspace::workspace(ref v) => {
my_size += ::protobuf::rt::string_size(4, &v);
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_password {
match v {
&UpdateUserRequest_oneof_one_of_password::password(ref v) => {
my_size += ::protobuf::rt::string_size(5, &v);
my_size += ::protobuf::rt::string_size(4, &v);
},
};
}
@ -393,17 +325,10 @@ impl ::protobuf::Message for UpdateUserRequest {
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_workspace {
match v {
&UpdateUserRequest_oneof_one_of_workspace::workspace(ref v) => {
os.write_string(4, v)?;
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_password {
match v {
&UpdateUserRequest_oneof_one_of_password::password(ref v) => {
os.write_string(5, v)?;
os.write_string(4, v)?;
},
};
}
@ -460,11 +385,6 @@ impl ::protobuf::Message for UpdateUserRequest {
UpdateUserRequest::has_email,
UpdateUserRequest::get_email,
));
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
"workspace",
UpdateUserRequest::has_workspace,
UpdateUserRequest::get_workspace,
));
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
"password",
UpdateUserRequest::has_password,
@ -489,7 +409,6 @@ impl ::protobuf::Clear for UpdateUserRequest {
self.id.clear();
self.one_of_name = ::std::option::Option::None;
self.one_of_email = ::std::option::Option::None;
self.one_of_workspace = ::std::option::Option::None;
self.one_of_password = ::std::option::Option::None;
self.unknown_fields.clear();
}
@ -514,7 +433,6 @@ pub struct UpdateUserParams {
// message oneof groups
pub one_of_name: ::std::option::Option<UpdateUserParams_oneof_one_of_name>,
pub one_of_email: ::std::option::Option<UpdateUserParams_oneof_one_of_email>,
pub one_of_workspace: ::std::option::Option<UpdateUserParams_oneof_one_of_workspace>,
pub one_of_password: ::std::option::Option<UpdateUserParams_oneof_one_of_password>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
@ -537,11 +455,6 @@ pub enum UpdateUserParams_oneof_one_of_email {
email(::std::string::String),
}
#[derive(Clone,PartialEq,Debug)]
pub enum UpdateUserParams_oneof_one_of_workspace {
workspace(::std::string::String),
}
#[derive(Clone,PartialEq,Debug)]
pub enum UpdateUserParams_oneof_one_of_password {
password(::std::string::String),
@ -676,56 +589,7 @@ impl UpdateUserParams {
}
}
// string workspace = 4;
pub fn get_workspace(&self) -> &str {
match self.one_of_workspace {
::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(ref v)) => v,
_ => "",
}
}
pub fn clear_workspace(&mut self) {
self.one_of_workspace = ::std::option::Option::None;
}
pub fn has_workspace(&self) -> bool {
match self.one_of_workspace {
::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(..)) => true,
_ => false,
}
}
// Param is passed by value, moved
pub fn set_workspace(&mut self, v: ::std::string::String) {
self.one_of_workspace = ::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(v))
}
// Mutable pointer to the field.
pub fn mut_workspace(&mut self) -> &mut ::std::string::String {
if let ::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(_)) = self.one_of_workspace {
} else {
self.one_of_workspace = ::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(::std::string::String::new()));
}
match self.one_of_workspace {
::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(ref mut v)) => v,
_ => panic!(),
}
}
// Take field
pub fn take_workspace(&mut self) -> ::std::string::String {
if self.has_workspace() {
match self.one_of_workspace.take() {
::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(v)) => v,
_ => panic!(),
}
} else {
::std::string::String::new()
}
}
// string password = 5;
// string password = 4;
pub fn get_password(&self) -> &str {
@ -800,12 +664,6 @@ impl ::protobuf::Message for UpdateUserParams {
self.one_of_email = ::std::option::Option::Some(UpdateUserParams_oneof_one_of_email::email(is.read_string()?));
},
4 => {
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
self.one_of_workspace = ::std::option::Option::Some(UpdateUserParams_oneof_one_of_workspace::workspace(is.read_string()?));
},
5 => {
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
@ -840,17 +698,10 @@ impl ::protobuf::Message for UpdateUserParams {
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_workspace {
match v {
&UpdateUserParams_oneof_one_of_workspace::workspace(ref v) => {
my_size += ::protobuf::rt::string_size(4, &v);
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_password {
match v {
&UpdateUserParams_oneof_one_of_password::password(ref v) => {
my_size += ::protobuf::rt::string_size(5, &v);
my_size += ::protobuf::rt::string_size(4, &v);
},
};
}
@ -877,17 +728,10 @@ impl ::protobuf::Message for UpdateUserParams {
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_workspace {
match v {
&UpdateUserParams_oneof_one_of_workspace::workspace(ref v) => {
os.write_string(4, v)?;
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_password {
match v {
&UpdateUserParams_oneof_one_of_password::password(ref v) => {
os.write_string(5, v)?;
os.write_string(4, v)?;
},
};
}
@ -944,11 +788,6 @@ impl ::protobuf::Message for UpdateUserParams {
UpdateUserParams::has_email,
UpdateUserParams::get_email,
));
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
"workspace",
UpdateUserParams::has_workspace,
UpdateUserParams::get_workspace,
));
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
"password",
UpdateUserParams::has_password,
@ -973,7 +812,6 @@ impl ::protobuf::Clear for UpdateUserParams {
self.id.clear();
self.one_of_name = ::std::option::Option::None;
self.one_of_email = ::std::option::Option::None;
self.one_of_workspace = ::std::option::Option::None;
self.one_of_password = ::std::option::Option::None;
self.unknown_fields.clear();
}
@ -992,57 +830,47 @@ impl ::protobuf::reflect::ProtobufValue for UpdateUserParams {
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x11user_update.proto\"\xd5\x01\n\x11UpdateUserRequest\x12\x0e\n\x02id\
\n\x11user_update.proto\"\xa1\x01\n\x11UpdateUserRequest\x12\x0e\n\x02id\
\x18\x01\x20\x01(\tR\x02id\x12\x14\n\x04name\x18\x02\x20\x01(\tH\0R\x04n\
ame\x12\x16\n\x05email\x18\x03\x20\x01(\tH\x01R\x05email\x12\x1e\n\twork\
space\x18\x04\x20\x01(\tH\x02R\tworkspace\x12\x1c\n\x08password\x18\x05\
\x20\x01(\tH\x03R\x08passwordB\r\n\x0bone_of_nameB\x0e\n\x0cone_of_email\
B\x12\n\x10one_of_workspaceB\x11\n\x0fone_of_password\"\xd4\x01\n\x10Upd\
ateUserParams\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x14\n\x04nam\
e\x18\x02\x20\x01(\tH\0R\x04name\x12\x16\n\x05email\x18\x03\x20\x01(\tH\
\x01R\x05email\x12\x1e\n\tworkspace\x18\x04\x20\x01(\tH\x02R\tworkspace\
\x12\x1c\n\x08password\x18\x05\x20\x01(\tH\x03R\x08passwordB\r\n\x0bone_\
of_nameB\x0e\n\x0cone_of_emailB\x12\n\x10one_of_workspaceB\x11\n\x0fone_\
of_passwordJ\xc0\x06\n\x06\x12\x04\0\0\x0f\x01\n\x08\n\x01\x0c\x12\x03\0\
\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x08\x01\n\n\n\x03\x04\0\x01\x12\x03\
\x02\x08\x19\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x12\n\x0c\n\x05\x04\
\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\
\x0b\r\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x10\x11\n\x0b\n\x04\x04\0\
\x08\0\x12\x03\x04\x04*\n\x0c\n\x05\x04\0\x08\0\x01\x12\x03\x04\n\x15\n\
\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x18(\n\x0c\n\x05\x04\0\x02\x01\x05\
\x12\x03\x04\x18\x1e\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x1f#\n\
\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04&'\n\x0b\n\x04\x04\0\x08\x01\x12\
\x03\x05\x04,\n\x0c\n\x05\x04\0\x08\x01\x01\x12\x03\x05\n\x16\n\x0b\n\
\x04\x04\0\x02\x02\x12\x03\x05\x19*\n\x0c\n\x05\x04\0\x02\x02\x05\x12\
\x03\x05\x19\x1f\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x05\x20%\n\x0c\n\
\x05\x04\0\x02\x02\x03\x12\x03\x05()\n\x0b\n\x04\x04\0\x08\x02\x12\x03\
\x06\x044\n\x0c\n\x05\x04\0\x08\x02\x01\x12\x03\x06\n\x1a\n\x0b\n\x04\
\x04\0\x02\x03\x12\x03\x06\x1d2\n\x0c\n\x05\x04\0\x02\x03\x05\x12\x03\
\x06\x1d#\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x06$-\n\x0c\n\x05\x04\0\
\x02\x03\x03\x12\x03\x0601\n\x0b\n\x04\x04\0\x08\x03\x12\x03\x07\x042\n\
\x0c\n\x05\x04\0\x08\x03\x01\x12\x03\x07\n\x19\n\x0b\n\x04\x04\0\x02\x04\
\x12\x03\x07\x1c0\n\x0c\n\x05\x04\0\x02\x04\x05\x12\x03\x07\x1c\"\n\x0c\
\n\x05\x04\0\x02\x04\x01\x12\x03\x07#+\n\x0c\n\x05\x04\0\x02\x04\x03\x12\
\x03\x07./\n\n\n\x02\x04\x01\x12\x04\t\0\x0f\x01\n\n\n\x03\x04\x01\x01\
\x12\x03\t\x08\x18\n\x0b\n\x04\x04\x01\x02\0\x12\x03\n\x04\x12\n\x0c\n\
\x05\x04\x01\x02\0\x05\x12\x03\n\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\
\x03\n\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\n\x10\x11\n\x0b\n\x04\
\x04\x01\x08\0\x12\x03\x0b\x04*\n\x0c\n\x05\x04\x01\x08\0\x01\x12\x03\
\x0b\n\x15\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x0b\x18(\n\x0c\n\x05\x04\
\x01\x02\x01\x05\x12\x03\x0b\x18\x1e\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\
\x03\x0b\x1f#\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x0b&'\n\x0b\n\x04\
\x04\x01\x08\x01\x12\x03\x0c\x04,\n\x0c\n\x05\x04\x01\x08\x01\x01\x12\
\x03\x0c\n\x16\n\x0b\n\x04\x04\x01\x02\x02\x12\x03\x0c\x19*\n\x0c\n\x05\
\x04\x01\x02\x02\x05\x12\x03\x0c\x19\x1f\n\x0c\n\x05\x04\x01\x02\x02\x01\
\x12\x03\x0c\x20%\n\x0c\n\x05\x04\x01\x02\x02\x03\x12\x03\x0c()\n\x0b\n\
\x04\x04\x01\x08\x02\x12\x03\r\x044\n\x0c\n\x05\x04\x01\x08\x02\x01\x12\
\x03\r\n\x1a\n\x0b\n\x04\x04\x01\x02\x03\x12\x03\r\x1d2\n\x0c\n\x05\x04\
\x01\x02\x03\x05\x12\x03\r\x1d#\n\x0c\n\x05\x04\x01\x02\x03\x01\x12\x03\
\r$-\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03\r01\n\x0b\n\x04\x04\x01\x08\
\x03\x12\x03\x0e\x042\n\x0c\n\x05\x04\x01\x08\x03\x01\x12\x03\x0e\n\x19\
\n\x0b\n\x04\x04\x01\x02\x04\x12\x03\x0e\x1c0\n\x0c\n\x05\x04\x01\x02\
\x04\x05\x12\x03\x0e\x1c\"\n\x0c\n\x05\x04\x01\x02\x04\x01\x12\x03\x0e#+\
\n\x0c\n\x05\x04\x01\x02\x04\x03\x12\x03\x0e./b\x06proto3\
ame\x12\x16\n\x05email\x18\x03\x20\x01(\tH\x01R\x05email\x12\x1c\n\x08pa\
ssword\x18\x04\x20\x01(\tH\x02R\x08passwordB\r\n\x0bone_of_nameB\x0e\n\
\x0cone_of_emailB\x11\n\x0fone_of_password\"\xa0\x01\n\x10UpdateUserPara\
ms\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x14\n\x04name\x18\x02\
\x20\x01(\tH\0R\x04name\x12\x16\n\x05email\x18\x03\x20\x01(\tH\x01R\x05e\
mail\x12\x1c\n\x08password\x18\x04\x20\x01(\tH\x02R\x08passwordB\r\n\x0b\
one_of_nameB\x0e\n\x0cone_of_emailB\x11\n\x0fone_of_passwordJ\x9c\x05\n\
\x06\x12\x04\0\0\r\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\
\x12\x04\x02\0\x07\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x19\n\x0b\n\
\x04\x04\0\x02\0\x12\x03\x03\x04\x12\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\
\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\r\n\x0c\n\x05\x04\
\0\x02\0\x03\x12\x03\x03\x10\x11\n\x0b\n\x04\x04\0\x08\0\x12\x03\x04\x04\
*\n\x0c\n\x05\x04\0\x08\0\x01\x12\x03\x04\n\x15\n\x0b\n\x04\x04\0\x02\
\x01\x12\x03\x04\x18(\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x18\x1e\
\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x1f#\n\x0c\n\x05\x04\0\x02\
\x01\x03\x12\x03\x04&'\n\x0b\n\x04\x04\0\x08\x01\x12\x03\x05\x04,\n\x0c\
\n\x05\x04\0\x08\x01\x01\x12\x03\x05\n\x16\n\x0b\n\x04\x04\0\x02\x02\x12\
\x03\x05\x19*\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x19\x1f\n\x0c\n\
\x05\x04\0\x02\x02\x01\x12\x03\x05\x20%\n\x0c\n\x05\x04\0\x02\x02\x03\
\x12\x03\x05()\n\x0b\n\x04\x04\0\x08\x02\x12\x03\x06\x042\n\x0c\n\x05\
\x04\0\x08\x02\x01\x12\x03\x06\n\x19\n\x0b\n\x04\x04\0\x02\x03\x12\x03\
\x06\x1c0\n\x0c\n\x05\x04\0\x02\x03\x05\x12\x03\x06\x1c\"\n\x0c\n\x05\
\x04\0\x02\x03\x01\x12\x03\x06#+\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\
\x06./\n\n\n\x02\x04\x01\x12\x04\x08\0\r\x01\n\n\n\x03\x04\x01\x01\x12\
\x03\x08\x08\x18\n\x0b\n\x04\x04\x01\x02\0\x12\x03\t\x04\x12\n\x0c\n\x05\
\x04\x01\x02\0\x05\x12\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\
\t\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\t\x10\x11\n\x0b\n\x04\x04\
\x01\x08\0\x12\x03\n\x04*\n\x0c\n\x05\x04\x01\x08\0\x01\x12\x03\n\n\x15\
\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\n\x18(\n\x0c\n\x05\x04\x01\x02\x01\
\x05\x12\x03\n\x18\x1e\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\n\x1f#\n\
\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\n&'\n\x0b\n\x04\x04\x01\x08\x01\
\x12\x03\x0b\x04,\n\x0c\n\x05\x04\x01\x08\x01\x01\x12\x03\x0b\n\x16\n\
\x0b\n\x04\x04\x01\x02\x02\x12\x03\x0b\x19*\n\x0c\n\x05\x04\x01\x02\x02\
\x05\x12\x03\x0b\x19\x1f\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\x0b\x20\
%\n\x0c\n\x05\x04\x01\x02\x02\x03\x12\x03\x0b()\n\x0b\n\x04\x04\x01\x08\
\x02\x12\x03\x0c\x042\n\x0c\n\x05\x04\x01\x08\x02\x01\x12\x03\x0c\n\x19\
\n\x0b\n\x04\x04\x01\x02\x03\x12\x03\x0c\x1c0\n\x0c\n\x05\x04\x01\x02\
\x03\x05\x12\x03\x0c\x1c\"\n\x0c\n\x05\x04\x01\x02\x03\x01\x12\x03\x0c#+\
\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03\x0c./b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -4,13 +4,11 @@ message UpdateUserRequest {
string id = 1;
oneof one_of_name { string name = 2; };
oneof one_of_email { string email = 3; };
oneof one_of_workspace { string workspace = 4; };
oneof one_of_password { string password = 5; };
oneof one_of_password { string password = 4; };
}
message UpdateUserParams {
string id = 1;
oneof one_of_name { string name = 2; };
oneof one_of_email { string email = 3; };
oneof one_of_workspace { string workspace = 4; };
oneof one_of_password { string password = 5; };
oneof one_of_password { string password = 4; };
}

View File

@ -161,20 +161,20 @@ impl UserSession {
}
}
pub async fn set_current_workspace(&self, workspace_id: &str) -> Result<(), UserError> {
let user_id = self.get_user_id()?;
let payload: Bytes = UpdateUserRequest::new(&user_id)
.workspace(workspace_id)
.into_bytes()
.unwrap();
let request = ModuleRequest::new(UpdateUser).payload(payload);
let _ = EventDispatch::async_send(request)
.await
.parse::<UserDetail, UserError>()
.unwrap()?;
Ok(())
}
// pub async fn set_current_workspace(&self, workspace_id: &str) -> Result<(),
// UserError> { let user_id = self.get_user_id()?;
// let payload: Bytes = UpdateUserRequest::new(&user_id)
// .workspace(workspace_id)
// .into_bytes()
// .unwrap();
//
// let request = ModuleRequest::new(UpdateUser).payload(payload);
// let _ = EventDispatch::async_send(request)
// .await
// .parse::<UserDetail, UserError>()
// .unwrap()?;
// Ok(())
// }
async fn create_default_workspace_if_need(&self, user_id: &str) -> Result<String, UserError> {
let key = format!("{}{}", user_id, DEFAULT_WORKSPACE);

View File

@ -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,

View File

@ -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))]

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -10,6 +10,7 @@ enum WsErrCode {
WorkspaceIdInvalid = 2;
AppColorStyleInvalid = 3;
WorkspaceDescInvalid = 4;
CurrentWorkspaceNotFound = 5;
AppIdInvalid = 10;
AppNameInvalid = 11;
ViewNameInvalid = 20;

View File

@ -6,6 +6,7 @@ enum WorkspaceEvent {
ReadWorkspace = 2;
DeleteWorkspace = 3;
ReadAllWorkspace = 4;
OpenWorkspace = 5;
CreateApp = 101;
DeleteApp = 102;
ReadApp = 103;

View File

@ -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,

View File

@ -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)
}