Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
bfd2dbfe
Commit
bfd2dbfe
authored
Oct 21, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix update resource api
parent
c42af95d
Changes
13
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
375 additions
and
281 deletions
+375
-281
resource_service.go
api/v2/resource_service.go
+6
-2
system_service.go
api/v2/system_service.go
+2
-2
resource_service.proto
proto/api/v2/resource_service.proto
+8
-6
system_service.proto
proto/api/v2/system_service.proto
+8
-3
user_service.proto
proto/api/v2/user_service.proto
+1
-1
README.md
proto/gen/api/v2/README.md
+2
-3
resource_service.pb.go
proto/gen/api/v2/resource_service.pb.go
+127
-127
resource_service.pb.gw.go
proto/gen/api/v2/resource_service.pb.gw.go
+44
-14
system_service.pb.go
proto/gen/api/v2/system_service.pb.go
+74
-64
system_service.pb.gw.go
proto/gen/api/v2/system_service.pb.gw.go
+33
-3
user_service.pb.go
proto/gen/api/v2/user_service.pb.go
+51
-51
user_service.pb.gw.go
proto/gen/api/v2/user_service.pb.gw.go
+18
-4
index.tsx
web/src/components/MemoEditor/index.tsx
+1
-1
No files found.
api/v2/resource_service.go
View file @
bfd2dbfe
...
@@ -58,12 +58,16 @@ func (s *ResourceService) ListResources(ctx context.Context, _ *apiv2pb.ListReso
...
@@ -58,12 +58,16 @@ func (s *ResourceService) ListResources(ctx context.Context, _ *apiv2pb.ListReso
}
}
func
(
s
*
ResourceService
)
UpdateResource
(
ctx
context
.
Context
,
request
*
apiv2pb
.
UpdateResourceRequest
)
(
*
apiv2pb
.
UpdateResourceResponse
,
error
)
{
func
(
s
*
ResourceService
)
UpdateResource
(
ctx
context
.
Context
,
request
*
apiv2pb
.
UpdateResourceRequest
)
(
*
apiv2pb
.
UpdateResourceResponse
,
error
)
{
if
request
.
UpdateMask
==
nil
||
len
(
request
.
UpdateMask
.
Paths
)
==
0
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"update mask is required"
)
}
currentTs
:=
time
.
Now
()
.
Unix
()
currentTs
:=
time
.
Now
()
.
Unix
()
update
:=
&
store
.
UpdateResource
{
update
:=
&
store
.
UpdateResource
{
ID
:
request
.
Id
,
ID
:
request
.
Resource
.
Id
,
UpdatedTs
:
&
currentTs
,
UpdatedTs
:
&
currentTs
,
}
}
for
_
,
field
:=
range
request
.
UpdateMask
{
for
_
,
field
:=
range
request
.
UpdateMask
.
Paths
{
if
field
==
"filename"
{
if
field
==
"filename"
{
update
.
Filename
=
&
request
.
Resource
.
Filename
update
.
Filename
=
&
request
.
Resource
.
Filename
}
else
if
field
==
"memo_id"
{
}
else
if
field
==
"memo_id"
{
...
...
api/v2/system_service.go
View file @
bfd2dbfe
...
@@ -57,12 +57,12 @@ func (s *SystemService) UpdateSystemInfo(ctx context.Context, request *apiv2pb.U
...
@@ -57,12 +57,12 @@ func (s *SystemService) UpdateSystemInfo(ctx context.Context, request *apiv2pb.U
if
user
.
Role
!=
store
.
RoleHost
{
if
user
.
Role
!=
store
.
RoleHost
{
return
nil
,
status
.
Errorf
(
codes
.
PermissionDenied
,
"permission denied"
)
return
nil
,
status
.
Errorf
(
codes
.
PermissionDenied
,
"permission denied"
)
}
}
if
request
.
UpdateMask
==
nil
||
len
(
request
.
UpdateMask
)
==
0
{
if
request
.
UpdateMask
==
nil
||
len
(
request
.
UpdateMask
.
Paths
)
==
0
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"update mask is required"
)
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"update mask is required"
)
}
}
// Update system settings.
// Update system settings.
for
_
,
path
:=
range
request
.
UpdateMask
{
for
_
,
path
:=
range
request
.
UpdateMask
.
Paths
{
if
path
==
"allow_registration"
{
if
path
==
"allow_registration"
{
_
,
err
:=
s
.
Store
.
UpsertSystemSetting
(
ctx
,
&
store
.
SystemSetting
{
_
,
err
:=
s
.
Store
.
UpsertSystemSetting
(
ctx
,
&
store
.
SystemSetting
{
Name
:
"allow-signup"
,
Name
:
"allow-signup"
,
...
...
proto/api/v2/resource_service.proto
View file @
bfd2dbfe
...
@@ -4,6 +4,7 @@ package memos.api.v2;
...
@@ -4,6 +4,7 @@ package memos.api.v2;
import
"google/api/annotations.proto"
;
import
"google/api/annotations.proto"
;
import
"google/api/client.proto"
;
import
"google/api/client.proto"
;
import
"google/protobuf/field_mask.proto"
;
import
"google/protobuf/timestamp.proto"
;
import
"google/protobuf/timestamp.proto"
;
option
go_package
=
"gen/api/v2"
;
option
go_package
=
"gen/api/v2"
;
...
@@ -16,8 +17,11 @@ service ResourceService {
...
@@ -16,8 +17,11 @@ service ResourceService {
option
(
google.api.http
)
=
{
get
:
"/api/v2/resources"
};
option
(
google.api.http
)
=
{
get
:
"/api/v2/resources"
};
}
}
rpc
UpdateResource
(
UpdateResourceRequest
)
returns
(
UpdateResourceResponse
)
{
rpc
UpdateResource
(
UpdateResourceRequest
)
returns
(
UpdateResourceResponse
)
{
option
(
google.api.http
)
=
{
put
:
"/api/v2/resources/{id}"
};
option
(
google.api.http
)
=
{
option
(
google.api.method_signature
)
=
"id"
;
patch
:
"/api/v2/resources/{resource.id}"
,
body
:
"resource"
};
option
(
google.api.method_signature
)
=
"resource,update_mask"
;
}
}
rpc
DeleteResource
(
DeleteResourceRequest
)
returns
(
DeleteResourceResponse
)
{
rpc
DeleteResource
(
DeleteResourceRequest
)
returns
(
DeleteResourceResponse
)
{
option
(
google.api.http
)
=
{
get
:
"/api/v2/resources/{id}"
};
option
(
google.api.http
)
=
{
get
:
"/api/v2/resources/{id}"
};
...
@@ -53,11 +57,9 @@ message ListResourcesResponse {
...
@@ -53,11 +57,9 @@ message ListResourcesResponse {
}
}
message
UpdateResourceRequest
{
message
UpdateResourceRequest
{
int32
id
=
1
;
Resource
resource
=
1
;
Resource
resource
=
2
;
repeated
string
update_mask
=
3
;
google.protobuf.FieldMask
update_mask
=
2
;
}
}
message
UpdateResourceResponse
{
message
UpdateResourceResponse
{
...
...
proto/api/v2/system_service.proto
View file @
bfd2dbfe
...
@@ -3,6 +3,8 @@ syntax = "proto3";
...
@@ -3,6 +3,8 @@ syntax = "proto3";
package
memos
.
api.v2
;
package
memos
.
api.v2
;
import
"google/api/annotations.proto"
;
import
"google/api/annotations.proto"
;
import
"google/api/client.proto"
;
import
"google/protobuf/field_mask.proto"
;
option
go_package
=
"gen/api/v2"
;
option
go_package
=
"gen/api/v2"
;
...
@@ -11,7 +13,11 @@ service SystemService {
...
@@ -11,7 +13,11 @@ service SystemService {
option
(
google.api.http
)
=
{
get
:
"/api/v2/system/info"
};
option
(
google.api.http
)
=
{
get
:
"/api/v2/system/info"
};
}
}
rpc
UpdateSystemInfo
(
UpdateSystemInfoRequest
)
returns
(
UpdateSystemInfoResponse
)
{
rpc
UpdateSystemInfo
(
UpdateSystemInfoRequest
)
returns
(
UpdateSystemInfoResponse
)
{
option
(
google.api.http
)
=
{
post
:
"/api/v2/system/info"
};
option
(
google.api.http
)
=
{
patch
:
"/api/v2/system/info"
,
body
:
"system_info"
};
option
(
google.api.method_signature
)
=
"system_info,update_mask"
;
}
}
}
}
...
@@ -34,8 +40,7 @@ message GetSystemInfoResponse {
...
@@ -34,8 +40,7 @@ message GetSystemInfoResponse {
message
UpdateSystemInfoRequest
{
message
UpdateSystemInfoRequest
{
// System info is the updated data.
// System info is the updated data.
SystemInfo
system_info
=
1
;
SystemInfo
system_info
=
1
;
// Update mask is the array of paths.
google.protobuf.FieldMask
update_mask
=
2
;
repeated
string
update_mask
=
2
;
}
}
message
UpdateSystemInfoResponse
{
message
UpdateSystemInfoResponse
{
...
...
proto/api/v2/user_service.proto
View file @
bfd2dbfe
...
@@ -25,7 +25,7 @@ service UserService {
...
@@ -25,7 +25,7 @@ service UserService {
}
}
rpc
UpdateUser
(
UpdateUserRequest
)
returns
(
UpdateUserResponse
)
{
rpc
UpdateUser
(
UpdateUserRequest
)
returns
(
UpdateUserResponse
)
{
option
(
google.api.http
)
=
{
option
(
google.api.http
)
=
{
p
ost
:
"/api/v2/users/{user.username=*
}"
p
atch
:
"/api/v2/users/{user.username
}"
body
:
"user"
body
:
"user"
};
};
option
(
google.api.method_signature
)
=
"user,update_mask"
;
option
(
google.api.method_signature
)
=
"user,update_mask"
;
...
...
proto/gen/api/v2/README.md
View file @
bfd2dbfe
...
@@ -448,9 +448,8 @@
...
@@ -448,9 +448,8 @@
| Field | Type | Label | Description |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| id |
[
int32
](
#int32
)
| | |
| resource |
[
Resource
](
#memos-api-v2-Resource
)
| | |
| resource |
[
Resource
](
#memos-api-v2-Resource
)
| | |
| update_mask |
[
string
](
#string
)
| repeated
| |
| update_mask |
[
google.protobuf.FieldMask
](
#google-protobuf-FieldMask
)
|
| |
...
@@ -556,7 +555,7 @@
...
@@ -556,7 +555,7 @@
| Field | Type | Label | Description |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| system_info |
[
SystemInfo
](
#memos-api-v2-SystemInfo
)
| | System info is the updated data. |
| system_info |
[
SystemInfo
](
#memos-api-v2-SystemInfo
)
| | System info is the updated data. |
| update_mask |
[
string
](
#string
)
| repeated | Update mask is the array of paths.
|
| update_mask |
[
google.protobuf.FieldMask
](
#google-protobuf-FieldMask
)
| |
|
...
...
proto/gen/api/v2/resource_service.pb.go
View file @
bfd2dbfe
This diff is collapsed.
Click to expand it.
proto/gen/api/v2/resource_service.pb.gw.go
View file @
bfd2dbfe
...
@@ -86,13 +86,28 @@ func local_request_ResourceService_ListResources_0(ctx context.Context, marshale
...
@@ -86,13 +86,28 @@ func local_request_ResourceService_ListResources_0(ctx context.Context, marshale
}
}
var
(
var
(
filter_ResourceService_UpdateResource_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{
"
id"
:
0
},
Base
:
[]
int
{
1
,
2
,
0
,
0
},
Check
:
[]
int
{
0
,
1
,
2
,
2
}}
filter_ResourceService_UpdateResource_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{
"
resource"
:
0
,
"id"
:
1
},
Base
:
[]
int
{
1
,
4
,
5
,
2
,
0
,
0
,
0
,
0
},
Check
:
[]
int
{
0
,
1
,
1
,
2
,
4
,
2
,
2
,
3
}}
)
)
func
request_ResourceService_UpdateResource_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ResourceServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
func
request_ResourceService_UpdateResource_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ResourceServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
UpdateResourceRequest
var
protoReq
UpdateResourceRequest
var
metadata
runtime
.
ServerMetadata
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
Resource
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
protoReq
.
UpdateMask
==
nil
||
len
(
protoReq
.
UpdateMask
.
GetPaths
())
==
0
{
if
fieldMask
,
err
:=
runtime
.
FieldMaskFromRequestBody
(
newReader
(),
protoReq
.
Resource
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
else
{
protoReq
.
UpdateMask
=
fieldMask
}
}
var
(
var
(
val
string
val
string
ok
bool
ok
bool
...
@@ -100,14 +115,14 @@ func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler run
...
@@ -100,14 +115,14 @@ func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler run
_
=
err
_
=
err
)
)
val
,
ok
=
pathParams
[
"id"
]
val
,
ok
=
pathParams
[
"
resource.
id"
]
if
!
ok
{
if
!
ok
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"id"
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"
resource.
id"
)
}
}
protoReq
.
Id
,
err
=
runtime
.
Int32
(
val
)
err
=
runtime
.
PopulateFieldFromPath
(
&
protoReq
,
"resource.id"
,
val
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"id"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"
resource.
id"
,
err
)
}
}
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
...
@@ -126,6 +141,21 @@ func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshal
...
@@ -126,6 +141,21 @@ func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshal
var
protoReq
UpdateResourceRequest
var
protoReq
UpdateResourceRequest
var
metadata
runtime
.
ServerMetadata
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
Resource
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
protoReq
.
UpdateMask
==
nil
||
len
(
protoReq
.
UpdateMask
.
GetPaths
())
==
0
{
if
fieldMask
,
err
:=
runtime
.
FieldMaskFromRequestBody
(
newReader
(),
protoReq
.
Resource
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
else
{
protoReq
.
UpdateMask
=
fieldMask
}
}
var
(
var
(
val
string
val
string
ok
bool
ok
bool
...
@@ -133,14 +163,14 @@ func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshal
...
@@ -133,14 +163,14 @@ func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshal
_
=
err
_
=
err
)
)
val
,
ok
=
pathParams
[
"id"
]
val
,
ok
=
pathParams
[
"
resource.
id"
]
if
!
ok
{
if
!
ok
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"id"
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"
resource.
id"
)
}
}
protoReq
.
Id
,
err
=
runtime
.
Int32
(
val
)
err
=
runtime
.
PopulateFieldFromPath
(
&
protoReq
,
"resource.id"
,
val
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"id"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"
resource.
id"
,
err
)
}
}
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
...
@@ -263,7 +293,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
...
@@ -263,7 +293,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
})
})
mux
.
Handle
(
"P
UT
"
,
pattern_ResourceService_UpdateResource_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
mux
.
Handle
(
"P
ATCH
"
,
pattern_ResourceService_UpdateResource_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
defer
cancel
()
var
stream
runtime
.
ServerTransportStream
var
stream
runtime
.
ServerTransportStream
...
@@ -271,7 +301,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
...
@@ -271,7 +301,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
var
err
error
var
err
error
var
annotatedContext
context
.
Context
var
annotatedContext
context
.
Context
annotatedContext
,
err
=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.ResourceService/UpdateResource"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/resources/{id}"
))
annotatedContext
,
err
=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.ResourceService/UpdateResource"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/resources/{
resource.
id}"
))
if
err
!=
nil
{
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
return
...
@@ -398,13 +428,13 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
...
@@ -398,13 +428,13 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
})
})
mux
.
Handle
(
"P
UT
"
,
pattern_ResourceService_UpdateResource_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
mux
.
Handle
(
"P
ATCH
"
,
pattern_ResourceService_UpdateResource_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
var
err
error
var
err
error
var
annotatedContext
context
.
Context
var
annotatedContext
context
.
Context
annotatedContext
,
err
=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.ResourceService/UpdateResource"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/resources/{id}"
))
annotatedContext
,
err
=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.ResourceService/UpdateResource"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/resources/{
resource.
id}"
))
if
err
!=
nil
{
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
return
...
@@ -450,7 +480,7 @@ var (
...
@@ -450,7 +480,7 @@ var (
pattern_ResourceService_ListResources_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"api"
,
"v2"
,
"resources"
},
""
))
pattern_ResourceService_ListResources_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"api"
,
"v2"
,
"resources"
},
""
))
pattern_ResourceService_UpdateResource_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
1
,
5
,
3
},
[]
string
{
"api"
,
"v2"
,
"resources"
,
"id"
},
""
))
pattern_ResourceService_UpdateResource_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
1
,
5
,
3
},
[]
string
{
"api"
,
"v2"
,
"resources"
,
"
resource.
id"
},
""
))
pattern_ResourceService_DeleteResource_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
1
,
5
,
3
},
[]
string
{
"api"
,
"v2"
,
"resources"
,
"id"
},
""
))
pattern_ResourceService_DeleteResource_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
1
,
5
,
3
},
[]
string
{
"api"
,
"v2"
,
"resources"
,
"id"
},
""
))
)
)
...
...
proto/gen/api/v2/system_service.pb.go
View file @
bfd2dbfe
This diff is collapsed.
Click to expand it.
proto/gen/api/v2/system_service.pb.gw.go
View file @
bfd2dbfe
...
@@ -50,13 +50,28 @@ func local_request_SystemService_GetSystemInfo_0(ctx context.Context, marshaler
...
@@ -50,13 +50,28 @@ func local_request_SystemService_GetSystemInfo_0(ctx context.Context, marshaler
}
}
var
(
var
(
filter_SystemService_UpdateSystemInfo_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{
},
Base
:
[]
int
(
nil
),
Check
:
[]
int
(
nil
)
}
filter_SystemService_UpdateSystemInfo_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{
"system_info"
:
0
,
"systemInfo"
:
1
},
Base
:
[]
int
{
1
,
1
,
2
,
0
,
0
},
Check
:
[]
int
{
0
,
1
,
1
,
2
,
3
}
}
)
)
func
request_SystemService_UpdateSystemInfo_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
SystemServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
func
request_SystemService_UpdateSystemInfo_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
SystemServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
UpdateSystemInfoRequest
var
protoReq
UpdateSystemInfoRequest
var
metadata
runtime
.
ServerMetadata
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
SystemInfo
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
protoReq
.
UpdateMask
==
nil
||
len
(
protoReq
.
UpdateMask
.
GetPaths
())
==
0
{
if
fieldMask
,
err
:=
runtime
.
FieldMaskFromRequestBody
(
newReader
(),
protoReq
.
SystemInfo
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
else
{
protoReq
.
UpdateMask
=
fieldMask
}
}
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
}
...
@@ -73,6 +88,21 @@ func local_request_SystemService_UpdateSystemInfo_0(ctx context.Context, marshal
...
@@ -73,6 +88,21 @@ func local_request_SystemService_UpdateSystemInfo_0(ctx context.Context, marshal
var
protoReq
UpdateSystemInfoRequest
var
protoReq
UpdateSystemInfoRequest
var
metadata
runtime
.
ServerMetadata
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
SystemInfo
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
protoReq
.
UpdateMask
==
nil
||
len
(
protoReq
.
UpdateMask
.
GetPaths
())
==
0
{
if
fieldMask
,
err
:=
runtime
.
FieldMaskFromRequestBody
(
newReader
(),
protoReq
.
SystemInfo
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
else
{
protoReq
.
UpdateMask
=
fieldMask
}
}
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
}
...
@@ -116,7 +146,7 @@ func RegisterSystemServiceHandlerServer(ctx context.Context, mux *runtime.ServeM
...
@@ -116,7 +146,7 @@ func RegisterSystemServiceHandlerServer(ctx context.Context, mux *runtime.ServeM
})
})
mux
.
Handle
(
"P
OST
"
,
pattern_SystemService_UpdateSystemInfo_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
mux
.
Handle
(
"P
ATCH
"
,
pattern_SystemService_UpdateSystemInfo_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
defer
cancel
()
var
stream
runtime
.
ServerTransportStream
var
stream
runtime
.
ServerTransportStream
...
@@ -204,7 +234,7 @@ func RegisterSystemServiceHandlerClient(ctx context.Context, mux *runtime.ServeM
...
@@ -204,7 +234,7 @@ func RegisterSystemServiceHandlerClient(ctx context.Context, mux *runtime.ServeM
})
})
mux
.
Handle
(
"P
OST
"
,
pattern_SystemService_UpdateSystemInfo_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
mux
.
Handle
(
"P
ATCH
"
,
pattern_SystemService_UpdateSystemInfo_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
...
...
proto/gen/api/v2/user_service.pb.go
View file @
bfd2dbfe
This diff is collapsed.
Click to expand it.
proto/gen/api/v2/user_service.pb.gw.go
View file @
bfd2dbfe
...
@@ -132,6 +132,13 @@ func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Mar
...
@@ -132,6 +132,13 @@ func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Mar
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
User
);
err
!=
nil
&&
err
!=
io
.
EOF
{
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
User
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
}
if
protoReq
.
UpdateMask
==
nil
||
len
(
protoReq
.
UpdateMask
.
GetPaths
())
==
0
{
if
fieldMask
,
err
:=
runtime
.
FieldMaskFromRequestBody
(
newReader
(),
protoReq
.
User
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
else
{
protoReq
.
UpdateMask
=
fieldMask
}
}
var
(
var
(
val
string
val
string
...
@@ -173,6 +180,13 @@ func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runti
...
@@ -173,6 +180,13 @@ func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runti
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
User
);
err
!=
nil
&&
err
!=
io
.
EOF
{
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
.
User
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
}
if
protoReq
.
UpdateMask
==
nil
||
len
(
protoReq
.
UpdateMask
.
GetPaths
())
==
0
{
if
fieldMask
,
err
:=
runtime
.
FieldMaskFromRequestBody
(
newReader
(),
protoReq
.
User
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
else
{
protoReq
.
UpdateMask
=
fieldMask
}
}
var
(
var
(
val
string
val
string
...
@@ -451,7 +465,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
...
@@ -451,7 +465,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
})
})
mux
.
Handle
(
"P
OST
"
,
pattern_UserService_UpdateUser_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
mux
.
Handle
(
"P
ATCH
"
,
pattern_UserService_UpdateUser_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
defer
cancel
()
var
stream
runtime
.
ServerTransportStream
var
stream
runtime
.
ServerTransportStream
...
@@ -459,7 +473,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
...
@@ -459,7 +473,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
var
err
error
var
err
error
var
annotatedContext
context
.
Context
var
annotatedContext
context
.
Context
annotatedContext
,
err
=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.UserService/UpdateUser"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/users/{user.username
=*
}"
))
annotatedContext
,
err
=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.UserService/UpdateUser"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/users/{user.username}"
))
if
err
!=
nil
{
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
return
...
@@ -636,13 +650,13 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
...
@@ -636,13 +650,13 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
})
})
mux
.
Handle
(
"P
OST
"
,
pattern_UserService_UpdateUser_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
mux
.
Handle
(
"P
ATCH
"
,
pattern_UserService_UpdateUser_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
var
err
error
var
err
error
var
annotatedContext
context
.
Context
var
annotatedContext
context
.
Context
annotatedContext
,
err
=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.UserService/UpdateUser"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/users/{user.username
=*
}"
))
annotatedContext
,
err
=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.UserService/UpdateUser"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/users/{user.username}"
))
if
err
!=
nil
{
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
return
...
...
web/src/components/MemoEditor/index.tsx
View file @
bfd2dbfe
...
@@ -247,8 +247,8 @@ const MemoEditor = (props: Props) => {
...
@@ -247,8 +247,8 @@ const MemoEditor = (props: Props) => {
uploadedResourceList
.
push
(
resource
);
uploadedResourceList
.
push
(
resource
);
if
(
memoId
)
{
if
(
memoId
)
{
await
resourceStore
.
updateResource
({
await
resourceStore
.
updateResource
({
id
:
resource
.
id
,
resource
:
Resource
.
fromPartial
({
resource
:
Resource
.
fromPartial
({
id
:
resource
.
id
,
memoId
,
memoId
,
}),
}),
updateMask
:
[
"memo_id"
],
updateMask
:
[
"memo_id"
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment