config view's update and query handle

This commit is contained in:
appflowy
2021-07-23 22:42:44 +08:00
parent 7e5c2cc62c
commit bfdc0b6ee9
38 changed files with 1317 additions and 62 deletions

View File

@ -1,4 +1,8 @@
mod parser;
mod view_create;
mod view_query;
mod view_update;
pub use view_create::*;
pub use view_query::*;
pub use view_update::*;

View File

@ -1,9 +1,11 @@
mod view_desc;
mod view_id;
mod view_name;
mod view_thumbnail;
mod view_type;
pub use view_desc::*;
pub use view_id::*;
pub use view_name::*;
pub use view_thumbnail::*;
pub use view_type::*;

View File

@ -0,0 +1,12 @@
#[derive(Debug)]
pub struct ViewId(pub String);
impl ViewId {
pub fn parse(s: String) -> Result<ViewId, String> {
if s.trim().is_empty() {
return Err(format!("View id can not be empty or whitespace"));
}
Ok(Self(s))
}
}

View File

@ -68,7 +68,7 @@ impl TryInto<CreateViewParams> for CreateViewRequest {
Some(thumbnail) => {
ViewThumbnail::parse(thumbnail)
.map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::ViewThumbnailName)
ErrorBuilder::new(WorkspaceErrorCode::ViewThumbnailInvalid)
.msg(e)
.build()
})?

View File

@ -0,0 +1,32 @@
use crate::{
entities::view::parser::ViewId,
errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode},
};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;
#[derive(Default, ProtoBuf)]
pub struct QueryViewRequest {
#[pb(index = 1)]
pub view_id: String,
}
pub struct QueryViewParams {
pub view_id: String,
}
impl TryInto<QueryViewParams> for QueryViewRequest {
type Error = WorkspaceError;
fn try_into(self) -> Result<QueryViewParams, Self::Error> {
let view_id = ViewId::parse(self.view_id)
.map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::ViewIdInvalid)
.msg(e)
.build()
})?
.0;
Ok(QueryViewParams { view_id })
}
}

View File

@ -0,0 +1,88 @@
use crate::{
entities::view::parser::{ViewId, *},
errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode},
};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;
#[derive(Default, ProtoBuf)]
pub struct UpdateViewRequest {
#[pb(index = 1)]
pub view_id: String,
#[pb(index = 2, one_of)]
pub name: Option<String>,
#[pb(index = 3, one_of)]
pub desc: Option<String>,
#[pb(index = 4, one_of)]
pub thumbnail: Option<String>,
}
pub struct UpdateViewParams {
pub view_id: String,
pub name: Option<String>,
pub desc: Option<String>,
pub thumbnail: Option<String>,
}
impl TryInto<UpdateViewParams> for UpdateViewRequest {
type Error = WorkspaceError;
fn try_into(self) -> Result<UpdateViewParams, Self::Error> {
let view_id = ViewId::parse(self.view_id)
.map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::ViewIdInvalid)
.msg(e)
.build()
})?
.0;
let name = match self.name {
None => None,
Some(name) => Some(
ViewName::parse(name)
.map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::ViewNameInvalid)
.msg(e)
.build()
})?
.0,
),
};
let desc = match self.desc {
None => None,
Some(desc) => Some(
ViewDesc::parse(desc)
.map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::ViewDescInvalid)
.msg(e)
.build()
})?
.0,
),
};
let thumbnail = match self.thumbnail {
None => None,
Some(thumbnail) => Some(
ViewThumbnail::parse(thumbnail)
.map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::ViewThumbnailInvalid)
.msg(e)
.build()
})?
.0,
),
};
Ok(UpdateViewParams {
view_id,
name,
desc,
thumbnail,
})
}
}

View File

@ -32,20 +32,26 @@ pub enum WorkspaceErrorCode {
#[display(fmt = "Workspace id is invalid")]
WorkspaceIdInvalid = 2,
#[display(fmt = "App color style format error")]
#[display(fmt = "Color style of the App is invalid")]
AppColorStyleInvalid = 3,
#[display(fmt = "App id is invalid")]
#[display(fmt = "Id of the App is invalid")]
AppIdInvalid = 10,
#[display(fmt = "App name is invalid")]
#[display(fmt = "Name of the App is invalid")]
AppNameInvalid = 11,
#[display(fmt = "View name is invalid")]
#[display(fmt = "Name of the View is invalid")]
ViewNameInvalid = 20,
#[display(fmt = "Thumbnail of the view is invalid")]
ViewThumbnailName = 21,
ViewThumbnailInvalid = 21,
#[display(fmt = "Id of the View is invalid")]
ViewIdInvalid = 22,
#[display(fmt = "Description of the View is invalid")]
ViewDescInvalid = 23,
#[display(fmt = "Get database connection failed")]
DatabaseConnectionFail = 100,

View File

@ -27,4 +27,12 @@ pub enum WorkspaceEvent {
#[display(fmt = "CreateView")]
#[event(input = "CreateViewRequest", output = "View")]
CreateView = 201,
#[display(fmt = "ReadView")]
#[event(input = "QueryViewRequest", output = "View")]
ReadView = 202,
#[display(fmt = "UpdateView")]
#[event(input = "UpdateViewRequest", output = "View")]
UpdateView = 203,
}

View File

@ -1,5 +1,13 @@
use crate::{
entities::view::{CreateViewParams, CreateViewRequest, View},
entities::view::{
CreateViewParams,
CreateViewRequest,
QueryViewParams,
QueryViewRequest,
UpdateViewParams,
UpdateViewRequest,
View,
},
errors::WorkspaceError,
services::ViewController,
};
@ -14,3 +22,23 @@ pub async fn create_view(
let view = controller.create_view(params).await?;
response_ok(view)
}
pub async fn read_view(
data: Data<QueryViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> ResponseResult<View, WorkspaceError> {
let params: QueryViewParams = data.into_inner().try_into()?;
let view = controller.read_view(&params.view_id).await?;
response_ok(view)
}
pub async fn update_view(
data: Data<UpdateViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> Result<(), WorkspaceError> {
let params: UpdateViewParams = data.into_inner().try_into()?;
let _ = controller.update_view(params).await?;
Ok(())
}

View File

@ -222,7 +222,9 @@ pub enum WorkspaceErrorCode {
AppIdInvalid = 10,
AppNameInvalid = 11,
ViewNameInvalid = 20,
ViewThumbnailName = 21,
ViewThumbnailInvalid = 21,
ViewIdInvalid = 22,
ViewDescInvalid = 23,
DatabaseConnectionFail = 100,
WorkspaceDatabaseError = 101,
UserInternalError = 102,
@ -243,7 +245,9 @@ impl ::protobuf::ProtobufEnum for WorkspaceErrorCode {
10 => ::std::option::Option::Some(WorkspaceErrorCode::AppIdInvalid),
11 => ::std::option::Option::Some(WorkspaceErrorCode::AppNameInvalid),
20 => ::std::option::Option::Some(WorkspaceErrorCode::ViewNameInvalid),
21 => ::std::option::Option::Some(WorkspaceErrorCode::ViewThumbnailName),
21 => ::std::option::Option::Some(WorkspaceErrorCode::ViewThumbnailInvalid),
22 => ::std::option::Option::Some(WorkspaceErrorCode::ViewIdInvalid),
23 => ::std::option::Option::Some(WorkspaceErrorCode::ViewDescInvalid),
100 => ::std::option::Option::Some(WorkspaceErrorCode::DatabaseConnectionFail),
101 => ::std::option::Option::Some(WorkspaceErrorCode::WorkspaceDatabaseError),
102 => ::std::option::Option::Some(WorkspaceErrorCode::UserInternalError),
@ -261,7 +265,9 @@ impl ::protobuf::ProtobufEnum for WorkspaceErrorCode {
WorkspaceErrorCode::AppIdInvalid,
WorkspaceErrorCode::AppNameInvalid,
WorkspaceErrorCode::ViewNameInvalid,
WorkspaceErrorCode::ViewThumbnailName,
WorkspaceErrorCode::ViewThumbnailInvalid,
WorkspaceErrorCode::ViewIdInvalid,
WorkspaceErrorCode::ViewDescInvalid,
WorkspaceErrorCode::DatabaseConnectionFail,
WorkspaceErrorCode::WorkspaceDatabaseError,
WorkspaceErrorCode::UserInternalError,
@ -296,21 +302,22 @@ impl ::protobuf::reflect::ProtobufValue for WorkspaceErrorCode {
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0cerrors.proto\"K\n\x0eWorkspaceError\x12'\n\x04code\x18\x01\x20\x01\
(\x0e2\x13.WorkspaceErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\
\tR\x03msg*\xa3\x02\n\x12WorkspaceErrorCode\x12\x0b\n\x07Unknown\x10\0\
\tR\x03msg*\xce\x02\n\x12WorkspaceErrorCode\x12\x0b\n\x07Unknown\x10\0\
\x12\x18\n\x14WorkspaceNameInvalid\x10\x01\x12\x16\n\x12WorkspaceIdInval\
id\x10\x02\x12\x18\n\x14AppColorStyleInvalid\x10\x03\x12\x10\n\x0cAppIdI\
nvalid\x10\n\x12\x12\n\x0eAppNameInvalid\x10\x0b\x12\x13\n\x0fViewNameIn\
valid\x10\x14\x12\x15\n\x11ViewThumbnailName\x10\x15\x12\x1a\n\x16Databa\
seConnectionFail\x10d\x12\x1a\n\x16WorkspaceDatabaseError\x10e\x12\x15\n\
\x11UserInternalError\x10f\x12\x13\n\x0fUserNotLoginYet\x10gJ\x9c\x05\n\
\x06\x12\x04\0\0\x13\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\
valid\x10\x14\x12\x18\n\x14ViewThumbnailInvalid\x10\x15\x12\x11\n\rViewI\
dInvalid\x10\x16\x12\x13\n\x0fViewDescInvalid\x10\x17\x12\x1a\n\x16Datab\
aseConnectionFail\x10d\x12\x1a\n\x16WorkspaceDatabaseError\x10e\x12\x15\
\n\x11UserInternalError\x10f\x12\x13\n\x0fUserNotLoginYet\x10gJ\xee\x05\
\n\x06\x12\x04\0\0\x15\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\x20\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\
\x03\x04\x16\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x17\x1b\n\x0c\n\x05\
\x04\0\x02\0\x03\x12\x03\x03\x1e\x1f\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\x13\x01\n\n\n\x03\x05\0\
\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x15\x01\n\n\n\x03\x05\0\
\x01\x12\x03\x06\x05\x17\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\
@ -326,16 +333,20 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x02\x05\x02\x12\x03\x0c\x15\x17\n\x0b\n\x04\x05\0\x02\x06\x12\x03\r\x04\
\x19\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x13\n\x0c\n\x05\x05\0\
\x02\x06\x02\x12\x03\r\x16\x18\n\x0b\n\x04\x05\0\x02\x07\x12\x03\x0e\x04\
\x1b\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x15\n\x0c\n\x05\x05\0\
\x02\x07\x02\x12\x03\x0e\x18\x1a\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0f\
\x04!\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x1a\n\x0c\n\x05\x05\
\0\x02\x08\x02\x12\x03\x0f\x1d\x20\n\x0b\n\x04\x05\0\x02\t\x12\x03\x10\
\x04!\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x10\x04\x1a\n\x0c\n\x05\x05\0\
\x02\t\x02\x12\x03\x10\x1d\x20\n\x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04\
\x1c\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\x15\n\x0c\n\x05\x05\0\
\x02\n\x02\x12\x03\x11\x18\x1b\n\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\
\x1a\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\x19b\x06proto3\
\x1e\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x18\n\x0c\n\x05\x05\0\
\x02\x07\x02\x12\x03\x0e\x1b\x1d\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0f\
\x04\x17\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x11\n\x0c\n\x05\
\x05\0\x02\x08\x02\x12\x03\x0f\x14\x16\n\x0b\n\x04\x05\0\x02\t\x12\x03\
\x10\x04\x19\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x10\x04\x13\n\x0c\n\x05\
\x05\0\x02\t\x02\x12\x03\x10\x16\x18\n\x0b\n\x04\x05\0\x02\n\x12\x03\x11\
\x04!\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\x1a\n\x0c\n\x05\x05\0\
\x02\n\x02\x12\x03\x11\x1d\x20\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\x1c\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\x13\x04\x15\n\x0c\n\x05\
\x05\0\x02\x0c\x02\x12\x03\x13\x18\x1b\n\x0b\n\x04\x05\0\x02\r\x12\x03\
\x14\x04\x1a\n\x0c\n\x05\x05\0\x02\r\x01\x12\x03\x14\x04\x13\n\x0c\n\x05\
\x05\0\x02\r\x02\x12\x03\x14\x16\x19b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -31,6 +31,8 @@ pub enum WorkspaceEvent {
CreateApp = 101,
GetApp = 102,
CreateView = 201,
ReadView = 202,
UpdateView = 203,
}
impl ::protobuf::ProtobufEnum for WorkspaceEvent {
@ -46,6 +48,8 @@ impl ::protobuf::ProtobufEnum for WorkspaceEvent {
101 => ::std::option::Option::Some(WorkspaceEvent::CreateApp),
102 => ::std::option::Option::Some(WorkspaceEvent::GetApp),
201 => ::std::option::Option::Some(WorkspaceEvent::CreateView),
202 => ::std::option::Option::Some(WorkspaceEvent::ReadView),
203 => ::std::option::Option::Some(WorkspaceEvent::UpdateView),
_ => ::std::option::Option::None
}
}
@ -58,6 +62,8 @@ impl ::protobuf::ProtobufEnum for WorkspaceEvent {
WorkspaceEvent::CreateApp,
WorkspaceEvent::GetApp,
WorkspaceEvent::CreateView,
WorkspaceEvent::ReadView,
WorkspaceEvent::UpdateView,
];
values
}
@ -86,24 +92,29 @@ impl ::protobuf::reflect::ProtobufValue for WorkspaceEvent {
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0bevent.proto*x\n\x0eWorkspaceEvent\x12\x13\n\x0fCreateWorkspace\x10\
\0\x12\x13\n\x0fGetCurWorkspace\x10\x01\x12\x10\n\x0cGetWorkspace\x10\
\x02\x12\r\n\tCreateApp\x10e\x12\n\n\x06GetApp\x10f\x12\x0f\n\nCreateVie\
w\x10\xc9\x01J\xa0\x02\n\x06\x12\x04\0\0\t\x01\n\x08\n\x01\x0c\x12\x03\0\
\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\t\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\x18\n\x0c\n\x05\x05\0\
\x02\x01\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\
\x04\x16\x17\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x05\x04\x15\n\x0c\n\x05\
\x05\0\x02\x02\x01\x12\x03\x05\x04\x10\n\x0c\n\x05\x05\0\x02\x02\x02\x12\
\x03\x05\x13\x14\n\x0b\n\x04\x05\0\x02\x03\x12\x03\x06\x04\x14\n\x0c\n\
\x05\x05\0\x02\x03\x01\x12\x03\x06\x04\r\n\x0c\n\x05\x05\0\x02\x03\x02\
\n\x0bevent.proto*\x98\x01\n\x0eWorkspaceEvent\x12\x13\n\x0fCreateWorksp\
ace\x10\0\x12\x13\n\x0fGetCurWorkspace\x10\x01\x12\x10\n\x0cGetWorkspace\
\x10\x02\x12\r\n\tCreateApp\x10e\x12\n\n\x06GetApp\x10f\x12\x0f\n\nCreat\
eView\x10\xc9\x01\x12\r\n\x08ReadView\x10\xca\x01\x12\x0f\n\nUpdateView\
\x10\xcb\x01J\xf2\x02\n\x06\x12\x04\0\0\x0b\x01\n\x08\n\x01\x0c\x12\x03\
\0\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\x0b\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\x18\n\x0c\n\x05\
\x05\0\x02\x01\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x05\0\x02\x01\x02\x12\
\x03\x04\x16\x17\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x05\x04\x15\n\x0c\n\
\x05\x05\0\x02\x02\x01\x12\x03\x05\x04\x10\n\x0c\n\x05\x05\0\x02\x02\x02\
\x12\x03\x05\x13\x14\n\x0b\n\x04\x05\0\x02\x03\x12\x03\x06\x04\x14\n\x0c\
\n\x05\x05\0\x02\x03\x01\x12\x03\x06\x04\r\n\x0c\n\x05\x05\0\x02\x03\x02\
\x12\x03\x06\x10\x13\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x07\x04\x11\n\x0c\
\n\x05\x05\0\x02\x04\x01\x12\x03\x07\x04\n\n\x0c\n\x05\x05\0\x02\x04\x02\
\x12\x03\x07\r\x10\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x08\x04\x15\n\x0c\n\
\x05\x05\0\x02\x05\x01\x12\x03\x08\x04\x0e\n\x0c\n\x05\x05\0\x02\x05\x02\
\x12\x03\x08\x11\x14b\x06proto3\
\x12\x03\x08\x11\x14\n\x0b\n\x04\x05\0\x02\x06\x12\x03\t\x04\x13\n\x0c\n\
\x05\x05\0\x02\x06\x01\x12\x03\t\x04\x0c\n\x0c\n\x05\x05\0\x02\x06\x02\
\x12\x03\t\x0f\x12\n\x0b\n\x04\x05\0\x02\x07\x12\x03\n\x04\x15\n\x0c\n\
\x05\x05\0\x02\x07\x01\x12\x03\n\x04\x0e\n\x0c\n\x05\x05\0\x02\x07\x02\
\x12\x03\n\x11\x14b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -1,5 +1,8 @@
// Auto-generated, do not edit
mod view_update;
pub use view_update::*;
mod app_query;
pub use app_query::*;
@ -32,3 +35,6 @@ pub use workspace_create::*;
mod app_update;
pub use app_update::*;
mod view_query;
pub use view_query::*;

View File

@ -0,0 +1,205 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `view_query.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct QueryViewRequest {
// message fields
pub view_id: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a QueryViewRequest {
fn default() -> &'a QueryViewRequest {
<QueryViewRequest as ::protobuf::Message>::default_instance()
}
}
impl QueryViewRequest {
pub fn new() -> QueryViewRequest {
::std::default::Default::default()
}
// string view_id = 1;
pub fn get_view_id(&self) -> &str {
&self.view_id
}
pub fn clear_view_id(&mut self) {
self.view_id.clear();
}
// Param is passed by value, moved
pub fn set_view_id(&mut self, v: ::std::string::String) {
self.view_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_view_id(&mut self) -> &mut ::std::string::String {
&mut self.view_id
}
// Take field
pub fn take_view_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.view_id, ::std::string::String::new())
}
}
impl ::protobuf::Message for QueryViewRequest {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.view_id)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.view_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.view_id);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.view_id.is_empty() {
os.write_string(1, &self.view_id)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> QueryViewRequest {
QueryViewRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"view_id",
|m: &QueryViewRequest| { &m.view_id },
|m: &mut QueryViewRequest| { &mut m.view_id },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<QueryViewRequest>(
"QueryViewRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static QueryViewRequest {
static instance: ::protobuf::rt::LazyV2<QueryViewRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(QueryViewRequest::new)
}
}
impl ::protobuf::Clear for QueryViewRequest {
fn clear(&mut self) {
self.view_id.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for QueryViewRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for QueryViewRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x10view_query.proto\"+\n\x10QueryViewRequest\x12\x17\n\x07view_id\x18\
\x01\x20\x01(\tR\x06viewIdJa\n\x06\x12\x04\0\0\x04\x01\n\x08\n\x01\x0c\
\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x04\x01\n\n\n\x03\x04\0\
\x01\x12\x03\x02\x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x17\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\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\x16b\
\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -0,0 +1,463 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `view_update.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct UpdateViewRequest {
// message fields
pub view_id: ::std::string::String,
// message oneof groups
pub one_of_name: ::std::option::Option<UpdateViewRequest_oneof_one_of_name>,
pub one_of_desc: ::std::option::Option<UpdateViewRequest_oneof_one_of_desc>,
pub one_of_thumbnail: ::std::option::Option<UpdateViewRequest_oneof_one_of_thumbnail>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a UpdateViewRequest {
fn default() -> &'a UpdateViewRequest {
<UpdateViewRequest as ::protobuf::Message>::default_instance()
}
}
#[derive(Clone,PartialEq,Debug)]
pub enum UpdateViewRequest_oneof_one_of_name {
name(::std::string::String),
}
#[derive(Clone,PartialEq,Debug)]
pub enum UpdateViewRequest_oneof_one_of_desc {
desc(::std::string::String),
}
#[derive(Clone,PartialEq,Debug)]
pub enum UpdateViewRequest_oneof_one_of_thumbnail {
thumbnail(::std::string::String),
}
impl UpdateViewRequest {
pub fn new() -> UpdateViewRequest {
::std::default::Default::default()
}
// string view_id = 1;
pub fn get_view_id(&self) -> &str {
&self.view_id
}
pub fn clear_view_id(&mut self) {
self.view_id.clear();
}
// Param is passed by value, moved
pub fn set_view_id(&mut self, v: ::std::string::String) {
self.view_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_view_id(&mut self) -> &mut ::std::string::String {
&mut self.view_id
}
// Take field
pub fn take_view_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.view_id, ::std::string::String::new())
}
// string name = 2;
pub fn get_name(&self) -> &str {
match self.one_of_name {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(ref v)) => v,
_ => "",
}
}
pub fn clear_name(&mut self) {
self.one_of_name = ::std::option::Option::None;
}
pub fn has_name(&self) -> bool {
match self.one_of_name {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(..)) => true,
_ => false,
}
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.one_of_name = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(v))
}
// Mutable pointer to the field.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
if let ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(_)) = self.one_of_name {
} else {
self.one_of_name = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(::std::string::String::new()));
}
match self.one_of_name {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(ref mut v)) => v,
_ => panic!(),
}
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
if self.has_name() {
match self.one_of_name.take() {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(v)) => v,
_ => panic!(),
}
} else {
::std::string::String::new()
}
}
// string desc = 3;
pub fn get_desc(&self) -> &str {
match self.one_of_desc {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(ref v)) => v,
_ => "",
}
}
pub fn clear_desc(&mut self) {
self.one_of_desc = ::std::option::Option::None;
}
pub fn has_desc(&self) -> bool {
match self.one_of_desc {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(..)) => true,
_ => false,
}
}
// Param is passed by value, moved
pub fn set_desc(&mut self, v: ::std::string::String) {
self.one_of_desc = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(v))
}
// Mutable pointer to the field.
pub fn mut_desc(&mut self) -> &mut ::std::string::String {
if let ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(_)) = self.one_of_desc {
} else {
self.one_of_desc = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(::std::string::String::new()));
}
match self.one_of_desc {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(ref mut v)) => v,
_ => panic!(),
}
}
// Take field
pub fn take_desc(&mut self) -> ::std::string::String {
if self.has_desc() {
match self.one_of_desc.take() {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(v)) => v,
_ => panic!(),
}
} else {
::std::string::String::new()
}
}
// string thumbnail = 4;
pub fn get_thumbnail(&self) -> &str {
match self.one_of_thumbnail {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(ref v)) => v,
_ => "",
}
}
pub fn clear_thumbnail(&mut self) {
self.one_of_thumbnail = ::std::option::Option::None;
}
pub fn has_thumbnail(&self) -> bool {
match self.one_of_thumbnail {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(..)) => true,
_ => false,
}
}
// Param is passed by value, moved
pub fn set_thumbnail(&mut self, v: ::std::string::String) {
self.one_of_thumbnail = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(v))
}
// Mutable pointer to the field.
pub fn mut_thumbnail(&mut self) -> &mut ::std::string::String {
if let ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(_)) = self.one_of_thumbnail {
} else {
self.one_of_thumbnail = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(::std::string::String::new()));
}
match self.one_of_thumbnail {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(ref mut v)) => v,
_ => panic!(),
}
}
// Take field
pub fn take_thumbnail(&mut self) -> ::std::string::String {
if self.has_thumbnail() {
match self.one_of_thumbnail.take() {
::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(v)) => v,
_ => panic!(),
}
} else {
::std::string::String::new()
}
}
}
impl ::protobuf::Message for UpdateViewRequest {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.view_id)?;
},
2 => {
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
self.one_of_name = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_name::name(is.read_string()?));
},
3 => {
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
self.one_of_desc = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_desc::desc(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_thumbnail = ::std::option::Option::Some(UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(is.read_string()?));
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.view_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.view_id);
}
if let ::std::option::Option::Some(ref v) = self.one_of_name {
match v {
&UpdateViewRequest_oneof_one_of_name::name(ref v) => {
my_size += ::protobuf::rt::string_size(2, &v);
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_desc {
match v {
&UpdateViewRequest_oneof_one_of_desc::desc(ref v) => {
my_size += ::protobuf::rt::string_size(3, &v);
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_thumbnail {
match v {
&UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(ref v) => {
my_size += ::protobuf::rt::string_size(4, &v);
},
};
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.view_id.is_empty() {
os.write_string(1, &self.view_id)?;
}
if let ::std::option::Option::Some(ref v) = self.one_of_name {
match v {
&UpdateViewRequest_oneof_one_of_name::name(ref v) => {
os.write_string(2, v)?;
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_desc {
match v {
&UpdateViewRequest_oneof_one_of_desc::desc(ref v) => {
os.write_string(3, v)?;
},
};
}
if let ::std::option::Option::Some(ref v) = self.one_of_thumbnail {
match v {
&UpdateViewRequest_oneof_one_of_thumbnail::thumbnail(ref v) => {
os.write_string(4, v)?;
},
};
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> UpdateViewRequest {
UpdateViewRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"view_id",
|m: &UpdateViewRequest| { &m.view_id },
|m: &mut UpdateViewRequest| { &mut m.view_id },
));
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
"name",
UpdateViewRequest::has_name,
UpdateViewRequest::get_name,
));
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
"desc",
UpdateViewRequest::has_desc,
UpdateViewRequest::get_desc,
));
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
"thumbnail",
UpdateViewRequest::has_thumbnail,
UpdateViewRequest::get_thumbnail,
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<UpdateViewRequest>(
"UpdateViewRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static UpdateViewRequest {
static instance: ::protobuf::rt::LazyV2<UpdateViewRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(UpdateViewRequest::new)
}
}
impl ::protobuf::Clear for UpdateViewRequest {
fn clear(&mut self) {
self.view_id.clear();
self.one_of_name = ::std::option::Option::None;
self.one_of_desc = ::std::option::Option::None;
self.one_of_thumbnail = ::std::option::Option::None;
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for UpdateViewRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for UpdateViewRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x11view_update.proto\"\xaa\x01\n\x11UpdateViewRequest\x12\x17\n\x07vi\
ew_id\x18\x01\x20\x01(\tR\x06viewId\x12\x14\n\x04name\x18\x02\x20\x01(\t\
H\0R\x04name\x12\x14\n\x04desc\x18\x03\x20\x01(\tH\x01R\x04desc\x12\x1e\
\n\tthumbnail\x18\x04\x20\x01(\tH\x02R\tthumbnailB\r\n\x0bone_of_nameB\r\
\n\x0bone_of_descB\x12\n\x10one_of_thumbnailJ\xd7\x02\n\x06\x12\x04\0\0\
\x07\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\x17\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\x12\n\x0c\n\x05\x04\0\x02\0\x03\
\x12\x03\x03\x15\x16\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\x15\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x18\
(\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x18\x1e\n\x0c\n\x05\x04\0\
\x02\x02\x01\x12\x03\x05\x1f#\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\x0601b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -12,7 +12,9 @@ enum WorkspaceErrorCode {
AppIdInvalid = 10;
AppNameInvalid = 11;
ViewNameInvalid = 20;
ViewThumbnailName = 21;
ViewThumbnailInvalid = 21;
ViewIdInvalid = 22;
ViewDescInvalid = 23;
DatabaseConnectionFail = 100;
WorkspaceDatabaseError = 101;
UserInternalError = 102;

View File

@ -7,4 +7,6 @@ enum WorkspaceEvent {
CreateApp = 101;
GetApp = 102;
CreateView = 201;
ReadView = 202;
UpdateView = 203;
}

View File

@ -0,0 +1,5 @@
syntax = "proto3";
message QueryViewRequest {
string view_id = 1;
}

View File

@ -0,0 +1,8 @@
syntax = "proto3";
message UpdateViewRequest {
string view_id = 1;
oneof one_of_name { string name = 2; };
oneof one_of_desc { string desc = 3; };
oneof one_of_thumbnail { string thumbnail = 4; };
}

View File

@ -1,9 +1,9 @@
use crate::{
entities::view::{CreateViewParams, View},
entities::view::{CreateViewParams, UpdateViewParams, View},
errors::WorkspaceError,
module::WorkspaceDatabase,
observable::{send_observable, WorkspaceObservable},
sql_tables::view::{ViewTable, ViewTableSql},
sql_tables::view::{ViewTable, ViewTableChangeset, ViewTableSql},
};
use std::sync::Arc;
@ -22,7 +22,22 @@ impl ViewController {
let view: View = view_table.clone().into();
let _ = self.sql.create_view(view_table)?;
send_observable(&view.id, WorkspaceObservable::AppAddView);
send_observable(&view.app_id, WorkspaceObservable::AppAddView);
Ok(view)
}
pub async fn read_view(&self, view_id: &str) -> Result<View, WorkspaceError> {
let view_table = self.sql.read_view(view_id)?;
let view: View = view_table.into();
Ok(view)
}
pub async fn update_view(&self, params: UpdateViewParams) -> Result<(), WorkspaceError> {
let changeset = ViewTableChangeset::new(params);
let view_id = changeset.id.clone();
let _ = self.sql.update_view(changeset)?;
send_observable(&view_id, WorkspaceObservable::ViewUpdateDesc);
Ok(())
}
}

View File

@ -1,9 +1,12 @@
use crate::{
errors::WorkspaceError,
module::WorkspaceDatabase,
sql_tables::{app::AppTable, view::ViewTable},
sql_tables::view::{ViewTable, ViewTableChangeset},
};
use flowy_database::{
prelude::*,
schema::{view_table, view_table::dsl},
};
use flowy_database::{prelude::*, schema::view_table};
use std::sync::Arc;
pub struct ViewTableSql {
@ -19,5 +22,19 @@ impl ViewTableSql {
Ok(())
}
pub(crate) fn read_view(&self, view_id: &str) -> Result<ViewTable, WorkspaceError> {
let view_table = dsl::view_table
.filter(view_table::id.eq(view_id))
.first::<ViewTable>(&*(self.database.db_connection()?))?;
Ok(view_table)
}
pub(crate) fn update_view(&self, changeset: ViewTableChangeset) -> Result<(), WorkspaceError> {
let conn = self.database.db_connection()?;
diesel_update_table!(view_table, changeset, conn);
Ok(())
}
pub fn delete_view(&self, view_id: &str) -> Result<(), WorkspaceError> { unimplemented!() }
}

View File

@ -1,5 +1,5 @@
use crate::{
entities::view::{CreateViewParams, View, ViewType},
entities::view::{CreateViewParams, UpdateViewParams, View, ViewType},
impl_sql_integer_expression,
sql_tables::app::AppTable,
};
@ -62,15 +62,17 @@ pub struct ViewTableChangeset {
pub id: String,
pub name: Option<String>,
pub desc: Option<String>,
pub thumbnail: Option<String>,
pub modified_time: i64,
}
impl ViewTableChangeset {
pub fn new(id: &str) -> Self {
pub fn new(params: UpdateViewParams) -> Self {
ViewTableChangeset {
id: id.to_string(),
name: None,
desc: None,
id: params.view_id,
name: params.name,
desc: params.desc,
thumbnail: params.thumbnail,
modified_time: timestamp(),
}
}