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
d6418f5f
Commit
d6418f5f
authored
Feb 04, 2022
by
email
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(go): use `json` instead of `jsonapi`
parent
a8f0c9a7
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
131 additions
and
109 deletions
+131
-109
auth.go
api/auth.go
+4
-4
memo.go
api/memo.go
+8
-8
resource.go
api/resource.go
+16
-16
shortcut.go
api/shortcut.go
+12
-14
user.go
api/user.go
+21
-13
go.mod
go.mod
+0
-1
go.sum
go.sum
+0
-2
auth.go
server/auth.go
+5
-5
memo.go
server/memo.go
+7
-7
resource.go
server/resource.go
+3
-3
server.go
server/server.go
+4
-3
shortcut.go
server/shortcut.go
+8
-17
user.go
server/user.go
+30
-4
webhook.go
server/webhook.go
+3
-3
10001_schema.sql
store/seed/10001_schema.sql
+2
-1
shortcut.go
store/shortcut.go
+8
-8
No files found.
api/auth.go
View file @
d6418f5f
package
api
package
api
type
Login
struct
{
type
Login
struct
{
Name
string
`json
api:"attr,
name"`
Name
string
`json
:"
name"`
Password
string
`json
api:"attr,
password"`
Password
string
`json
:"
password"`
}
}
type
Signup
struct
{
type
Signup
struct
{
Name
string
`json
api:"attr,
name"`
Name
string
`json
:"
name"`
Password
string
`json
api:"attr,
password"`
Password
string
`json
:"
password"`
}
}
api/memo.go
View file @
d6418f5f
package
api
package
api
type
Memo
struct
{
type
Memo
struct
{
Id
int
`json
api:"primary,memo
"`
Id
int
`json
:"id
"`
CreatedTs
int64
`json
api:"attr,
createdTs"`
CreatedTs
int64
`json
:"
createdTs"`
UpdatedTs
int64
`json
api:"attr,
updatedTs"`
UpdatedTs
int64
`json
:"
updatedTs"`
RowStatus
string
`json
api:"attr,
rowStatus"`
RowStatus
string
`json
:"
rowStatus"`
Content
string
`json
api:"attr,
content"`
Content
string
`json
:"
content"`
CreatorId
int
`json
api:"attr,
creatorId"`
CreatorId
int
`json
:"
creatorId"`
}
}
type
MemoCreate
struct
{
type
MemoCreate
struct
{
Content
string
`json
api:"attr,
content"`
Content
string
`json
:"
content"`
CreatorId
int
CreatorId
int
}
}
...
@@ -28,7 +28,7 @@ type MemoFind struct {
...
@@ -28,7 +28,7 @@ type MemoFind struct {
}
}
type
MemoDelete
struct
{
type
MemoDelete
struct
{
Id
*
int
`json
api:"primary,memo
"`
Id
*
int
`json
:"id
"`
CreatorId
*
int
CreatorId
*
int
}
}
...
...
api/resource.go
View file @
d6418f5f
package
api
package
api
type
Resource
struct
{
type
Resource
struct
{
Id
int
`json
api:"primary,resource
"`
Id
int
`json
:"id
"`
CreatedTs
int64
`json
api:"attr,
createdTs"`
CreatedTs
int64
`json
:"
createdTs"`
UpdatedTs
int64
`json
api:"attr,
updatedTs"`
UpdatedTs
int64
`json
:"
updatedTs"`
Filename
string
`json
api:"attr,
filename"`
Filename
string
`json
:"
filename"`
Blob
[]
byte
`json
api:"attr,
blob"`
Blob
[]
byte
`json
:"
blob"`
Type
string
`json
api:"attr,
type"`
Type
string
`json
:"
type"`
Size
int64
`json
api:"attr,
size"`
Size
int64
`json
:"
size"`
CreatorId
int
`json
api:"attr,
creatorId"`
CreatorId
int
`json
:"
creatorId"`
}
}
type
ResourceCreate
struct
{
type
ResourceCreate
struct
{
Filename
string
`json
api:"attr,
filename"`
Filename
string
`json
:"
filename"`
Blob
[]
byte
`json
api:"attr,
blob"`
Blob
[]
byte
`json
:"
blob"`
Type
string
`json
api:"attr,
type"`
Type
string
`json
:"
type"`
Size
int64
`json
api:"attr,
size"`
Size
int64
`json
:"
size"`
CreatorId
int
`jsonapi:"attr,creatorId"`
CreatorId
int
}
}
type
ResourceFind
struct
{
type
ResourceFind
struct
{
Id
*
int
Id
*
int
`json:"id"`
CreatorId
*
int
CreatorId
*
int
`json:"creatorId"`
Filename
*
string
Filename
*
string
`json:"filename"`
}
}
type
ResourceDelete
struct
{
type
ResourceDelete
struct
{
...
...
api/shortcut.go
View file @
d6418f5f
package
api
package
api
type
Shortcut
struct
{
type
Shortcut
struct
{
Id
int
`json
api:"primary,shortcut
"`
Id
int
`json
:"id
"`
CreatedTs
int64
`json
api:"attr,
createdTs"`
CreatedTs
int64
`json
:"
createdTs"`
UpdatedTs
int64
`json
api:"attr,
updatedTs"`
UpdatedTs
int64
`json
:"
updatedTs"`
Title
string
`json
api:"attr,
title"`
Title
string
`json
:"
title"`
Payload
string
`json
api:"attr,
payload"`
Payload
string
`json
:"
payload"`
PinnedTs
int64
`jsonapi:"attr,pinnedT
s"`
RowStatus
string
`json:"rowStatu
s"`
CreatorId
int
CreatorId
int
}
}
...
@@ -16,18 +16,16 @@ type ShortcutCreate struct {
...
@@ -16,18 +16,16 @@ type ShortcutCreate struct {
CreatorId
int
CreatorId
int
// Domain specific fields
// Domain specific fields
Title
string
`json
api:"attr,
title"`
Title
string
`json
:"
title"`
Payload
string
`json
api:"attr,
payload"`
Payload
string
`json
:"
payload"`
}
}
type
ShortcutPatch
struct
{
type
ShortcutPatch
struct
{
Id
int
Id
int
Title
*
string
`jsonapi:"attr,title"`
Title
*
string
`json:"title"`
Payload
*
string
`jsonapi:"attr,payload"`
Payload
*
string
`json:"payload"`
PinnedTs
*
int64
RowStatus
*
string
`json:"rowStatus"`
Pinned
*
bool
`jsonapi:"attr,pinned"`
}
}
type
ShortcutFind
struct
{
type
ShortcutFind
struct
{
...
@@ -37,7 +35,7 @@ type ShortcutFind struct {
...
@@ -37,7 +35,7 @@ type ShortcutFind struct {
CreatorId
*
int
CreatorId
*
int
// Domain specific fields
// Domain specific fields
Title
*
string
`json
api:"attr,
title"`
Title
*
string
`json
:"
title"`
}
}
type
ShortcutDelete
struct
{
type
ShortcutDelete
struct
{
...
...
api/user.go
View file @
d6418f5f
package
api
package
api
type
User
struct
{
type
User
struct
{
Id
int
`json
api:"primary,user
"`
Id
int
`json
:"id
"`
CreatedTs
int64
`json
api:"attr,
createdTs"`
CreatedTs
int64
`json
:"
createdTs"`
UpdatedTs
int64
`json
api:"attr,
updatedTs"`
UpdatedTs
int64
`json
:"
updatedTs"`
OpenId
string
`json
api:"attr,
openId"`
OpenId
string
`json
:"
openId"`
Name
string
`json
api:"attr,
name"`
Name
string
`json
:"
name"`
Password
string
Password
string
}
}
type
UserCreate
struct
{
type
UserCreate
struct
{
OpenId
string
`json
api:"attr,
openId"`
OpenId
string
`json
:"
openId"`
Name
string
`json
api:"attr,
name"`
Name
string
`json
:"
name"`
Password
string
`json
api:"attr,
password"`
Password
string
`json
:"
password"`
}
}
type
UserPatch
struct
{
type
UserPatch
struct
{
...
@@ -21,18 +21,26 @@ type UserPatch struct {
...
@@ -21,18 +21,26 @@ type UserPatch struct {
OpenId
*
string
OpenId
*
string
Name
*
string
`json
api:"attr,
name"`
Name
*
string
`json
:"
name"`
Password
*
string
`json
api:"attr,
password"`
Password
*
string
`json
:"
password"`
ResetOpenId
*
bool
`json
api:"attr,
resetOpenId"`
ResetOpenId
*
bool
`json
:"
resetOpenId"`
}
}
type
UserFind
struct
{
type
UserFind
struct
{
Id
*
int
`json
api:"attr,
id"`
Id
*
int
`json
:"
id"`
Name
*
string
`json
api:"attr,
name"`
Name
*
string
`json
:"
name"`
OpenId
*
string
OpenId
*
string
}
}
type
UserRenameCheck
struct
{
Name
string
`json:"name"`
}
type
UserPasswordCheck
struct
{
Password
string
`json:"password"`
}
type
UserService
interface
{
type
UserService
interface
{
CreateUser
(
create
*
UserCreate
)
(
*
User
,
error
)
CreateUser
(
create
*
UserCreate
)
(
*
User
,
error
)
PatchUser
(
patch
*
UserPatch
)
(
*
User
,
error
)
PatchUser
(
patch
*
UserPatch
)
(
*
User
,
error
)
...
...
go.mod
View file @
d6418f5f
...
@@ -23,7 +23,6 @@ require (
...
@@ -23,7 +23,6 @@ require (
)
)
require (
require (
github.com/google/jsonapi v1.0.0
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/sessions v1.2.1
github.com/gorilla/sessions v1.2.1
github.com/labstack/echo-contrib v0.12.0
github.com/labstack/echo-contrib v0.12.0
...
...
go.sum
View file @
d6418f5f
...
@@ -133,8 +133,6 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
...
@@ -133,8 +133,6 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/jsonapi v1.0.0 h1:qIGgO5Smu3yJmSs+QlvhQnrscdZfFhiV6S8ryJAglqU=
github.com/google/jsonapi v1.0.0/go.mod h1:YYHiRPJT8ARXGER8In9VuLv4qvLfDmA9ULQqptbLE4s=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
...
...
server/auth.go
View file @
d6418f5f
package
server
package
server
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"memos/api"
"memos/api"
"memos/common"
"memos/common"
"net/http"
"net/http"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4"
)
)
func
(
s
*
Server
)
registerAuthRoutes
(
g
*
echo
.
Group
)
{
func
(
s
*
Server
)
registerAuthRoutes
(
g
*
echo
.
Group
)
{
g
.
POST
(
"/auth/login"
,
func
(
c
echo
.
Context
)
error
{
g
.
POST
(
"/auth/login"
,
func
(
c
echo
.
Context
)
error
{
login
:=
&
api
.
Login
{}
login
:=
&
api
.
Login
{}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
login
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
login
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted login request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted login request"
)
.
SetInternal
(
err
)
}
}
...
@@ -40,7 +40,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
...
@@ -40,7 +40,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
user
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal create user response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal create user response"
)
.
SetInternal
(
err
)
}
}
...
@@ -57,7 +57,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
...
@@ -57,7 +57,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
})
})
g
.
POST
(
"/auth/signup"
,
func
(
c
echo
.
Context
)
error
{
g
.
POST
(
"/auth/signup"
,
func
(
c
echo
.
Context
)
error
{
signup
:=
&
api
.
Signup
{}
signup
:=
&
api
.
Signup
{}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
signup
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
signup
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted signup request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted signup request"
)
.
SetInternal
(
err
)
}
}
...
@@ -88,7 +88,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
...
@@ -88,7 +88,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
user
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal create user response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal create user response"
)
.
SetInternal
(
err
)
}
}
...
...
server/memo.go
View file @
d6418f5f
package
server
package
server
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"memos/api"
"memos/api"
"memos/common"
"memos/common"
"net/http"
"net/http"
"strconv"
"strconv"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4"
)
)
...
@@ -17,7 +17,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -17,7 +17,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
memoCreate
:=
&
api
.
MemoCreate
{
memoCreate
:=
&
api
.
MemoCreate
{
CreatorId
:
userId
,
CreatorId
:
userId
,
}
}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
memoCreate
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
memoCreate
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post memo request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post memo request"
)
.
SetInternal
(
err
)
}
}
...
@@ -27,7 +27,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -27,7 +27,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
memo
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
memo
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
}
}
...
@@ -42,7 +42,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -42,7 +42,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
memoPatch
:=
&
api
.
MemoPatch
{
memoPatch
:=
&
api
.
MemoPatch
{
Id
:
memoId
,
Id
:
memoId
,
}
}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
memoPatch
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
memoPatch
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted patch memo request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted patch memo request"
)
.
SetInternal
(
err
)
}
}
...
@@ -52,7 +52,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -52,7 +52,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
memo
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
memo
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
}
}
...
@@ -69,7 +69,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -69,7 +69,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
list
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
list
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo list response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo list response"
)
.
SetInternal
(
err
)
}
}
...
@@ -93,7 +93,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -93,7 +93,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
memo
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
memo
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
}
}
...
...
server/resource.go
View file @
d6418f5f
package
server
package
server
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"memos/api"
"memos/api"
"net/http"
"net/http"
"strconv"
"strconv"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4"
)
)
...
@@ -53,7 +53,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -53,7 +53,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
resource
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
resource
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
}
}
...
@@ -70,7 +70,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -70,7 +70,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
list
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
list
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal resource list response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal resource list response"
)
.
SetInternal
(
err
)
}
}
...
...
server/server.go
View file @
d6418f5f
...
@@ -29,9 +29,10 @@ func NewServer() *Server {
...
@@ -29,9 +29,10 @@ func NewServer() *Server {
e
.
HidePort
=
false
e
.
HidePort
=
false
e
.
Use
(
middleware
.
StaticWithConfig
(
middleware
.
StaticConfig
{
e
.
Use
(
middleware
.
StaticWithConfig
(
middleware
.
StaticConfig
{
Root
:
"web/dist"
,
Skipper
:
middleware
.
DefaultSkipper
,
Browse
:
false
,
Root
:
"web/dist"
,
HTML5
:
true
,
Browse
:
false
,
HTML5
:
true
,
}))
}))
e
.
Use
(
session
.
Middleware
(
sessions
.
NewCookieStore
([]
byte
(
common
.
GenUUID
()))))
e
.
Use
(
session
.
Middleware
(
sessions
.
NewCookieStore
([]
byte
(
common
.
GenUUID
()))))
...
...
server/shortcut.go
View file @
d6418f5f
package
server
package
server
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"memos/api"
"memos/api"
"net/http"
"net/http"
"strconv"
"strconv"
"time"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4"
)
)
...
@@ -17,7 +16,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
...
@@ -17,7 +16,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
shortcutCreate
:=
&
api
.
ShortcutCreate
{
shortcutCreate
:=
&
api
.
ShortcutCreate
{
CreatorId
:
userId
,
CreatorId
:
userId
,
}
}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
shortcutCreate
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
shortcutCreate
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post shortcut request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post shortcut request"
)
.
SetInternal
(
err
)
}
}
...
@@ -27,7 +26,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
...
@@ -27,7 +26,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
shortcut
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
shortcut
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
}
}
...
@@ -42,25 +41,17 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
...
@@ -42,25 +41,17 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
shortcutPatch
:=
&
api
.
ShortcutPatch
{
shortcutPatch
:=
&
api
.
ShortcutPatch
{
Id
:
shortcutId
,
Id
:
shortcutId
,
}
}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
shortcutPatch
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
shortcutPatch
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted patch shortcut request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted patch shortcut request"
)
.
SetInternal
(
err
)
}
}
if
shortcutPatch
.
Pinned
!=
nil
{
pinnedTs
:=
int64
(
0
)
if
*
shortcutPatch
.
Pinned
{
pinnedTs
=
time
.
Now
()
.
Unix
()
}
shortcutPatch
.
PinnedTs
=
&
pinnedTs
}
shortcut
,
err
:=
s
.
ShortcutService
.
PatchShortcut
(
shortcutPatch
)
shortcut
,
err
:=
s
.
ShortcutService
.
PatchShortcut
(
shortcutPatch
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to patch shortcut"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to patch shortcut"
)
.
SetInternal
(
err
)
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
shortcut
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
shortcut
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
}
}
...
@@ -71,13 +62,13 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
...
@@ -71,13 +62,13 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
shortcutFind
:=
&
api
.
ShortcutFind
{
shortcutFind
:=
&
api
.
ShortcutFind
{
CreatorId
:
&
userId
,
CreatorId
:
&
userId
,
}
}
list
,
err
:=
s
.
ShortcutService
.
FindShortcut
(
shortcutFind
)
list
,
err
:=
s
.
ShortcutService
.
FindShortcut
List
(
shortcutFind
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch shortcut list"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch shortcut list"
)
.
SetInternal
(
err
)
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
list
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
list
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut list response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut list response"
)
.
SetInternal
(
err
)
}
}
...
@@ -98,7 +89,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
...
@@ -98,7 +89,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
shortcut
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
shortcut
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal shortcut response"
)
.
SetInternal
(
err
)
}
}
...
...
server/user.go
View file @
d6418f5f
package
server
package
server
import
(
import
(
"encoding/json"
"memos/api"
"memos/api"
"memos/common"
"memos/common"
"net/http"
"net/http"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4"
)
)
...
@@ -21,9 +21,35 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
...
@@ -21,9 +21,35 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
user
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal user response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal user response"
)
.
SetInternal
(
err
)
}
}
return
nil
})
g
.
POST
(
"/user/rename_check"
,
func
(
c
echo
.
Context
)
error
{
userRenameCheck
:=
&
api
.
UserRenameCheck
{}
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
userRenameCheck
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post user rename check request"
)
.
SetInternal
(
err
)
}
if
userRenameCheck
.
Name
==
""
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post user rename check request"
)
}
userFind
:=
&
api
.
UserFind
{
Name
:
&
userRenameCheck
.
Name
,
}
user
,
err
:=
s
.
UserService
.
FindUser
(
userFind
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find user"
)
.
SetInternal
(
err
)
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal user response"
)
.
SetInternal
(
err
)
}
return
nil
return
nil
})
})
g
.
PATCH
(
"user/me"
,
func
(
c
echo
.
Context
)
error
{
g
.
PATCH
(
"user/me"
,
func
(
c
echo
.
Context
)
error
{
...
@@ -31,7 +57,7 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
...
@@ -31,7 +57,7 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
userPatch
:=
&
api
.
UserPatch
{
userPatch
:=
&
api
.
UserPatch
{
Id
:
userId
,
Id
:
userId
,
}
}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
userPatch
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
userPatch
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted patch user request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted patch user request"
)
.
SetInternal
(
err
)
}
}
...
@@ -46,7 +72,7 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
...
@@ -46,7 +72,7 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
user
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal user response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal user response"
)
.
SetInternal
(
err
)
}
}
...
...
server/webhook.go
View file @
d6418f5f
package
server
package
server
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"memos/api"
"memos/api"
"net/http"
"net/http"
"strconv"
"strconv"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4"
)
)
...
@@ -31,7 +31,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
...
@@ -31,7 +31,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
memoCreate
:=
&
api
.
MemoCreate
{
memoCreate
:=
&
api
.
MemoCreate
{
CreatorId
:
user
.
Id
,
CreatorId
:
user
.
Id
,
}
}
if
err
:=
json
api
.
UnmarshalPayload
(
c
.
Request
()
.
Body
,
memoCreate
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
memoCreate
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post memo request by open api"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post memo request by open api"
)
.
SetInternal
(
err
)
}
}
...
@@ -41,7 +41,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
...
@@ -41,7 +41,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
}
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
api
.
MarshalPayload
(
c
.
Response
()
.
Writer
,
memo
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
memo
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to marshal memo response"
)
.
SetInternal
(
err
)
}
}
...
...
store/seed/10001_schema.sql
View file @
d6418f5f
...
@@ -64,7 +64,8 @@ CREATE TABLE shortcut (
...
@@ -64,7 +64,8 @@ CREATE TABLE shortcut (
title
TEXT
NOT
NULL
DEFAULT
''
,
title
TEXT
NOT
NULL
DEFAULT
''
,
payload
TEXT
NOT
NULL
DEFAULT
''
,
payload
TEXT
NOT
NULL
DEFAULT
''
,
creator_id
INTEGER
NOT
NULL
,
creator_id
INTEGER
NOT
NULL
,
pinned_ts
BIGINT
NOT
NULL
DEFAULT
0
,
-- allowed row status are 'NORMAL', 'ARCHIVED'.
row_status
TEXT
NOT
NULL
DEFAULT
'NORMAL'
,
FOREIGN
KEY
(
creator_id
)
REFERENCES
users
(
id
)
FOREIGN
KEY
(
creator_id
)
REFERENCES
users
(
id
)
);
);
...
...
store/shortcut.go
View file @
d6418f5f
...
@@ -72,7 +72,7 @@ func createShortcut(db *DB, create *api.ShortcutCreate) (*api.Shortcut, error) {
...
@@ -72,7 +72,7 @@ func createShortcut(db *DB, create *api.ShortcutCreate) (*api.Shortcut, error) {
creator_id,
creator_id,
)
)
VALUES (?, ?, ?)
VALUES (?, ?, ?)
RETURNING id, title, payload, creator_id, created_ts, updated_ts,
pinned_t
s
RETURNING id, title, payload, creator_id, created_ts, updated_ts,
row_statu
s
`
,
`
,
create
.
Title
,
create
.
Title
,
create
.
Payload
,
create
.
Payload
,
...
@@ -93,7 +93,7 @@ func createShortcut(db *DB, create *api.ShortcutCreate) (*api.Shortcut, error) {
...
@@ -93,7 +93,7 @@ func createShortcut(db *DB, create *api.ShortcutCreate) (*api.Shortcut, error) {
&
shortcut
.
CreatorId
,
&
shortcut
.
CreatorId
,
&
shortcut
.
CreatedTs
,
&
shortcut
.
CreatedTs
,
&
shortcut
.
UpdatedTs
,
&
shortcut
.
UpdatedTs
,
&
shortcut
.
PinnedT
s
,
&
shortcut
.
RowStatu
s
,
);
err
!=
nil
{
);
err
!=
nil
{
return
nil
,
FormatError
(
err
)
return
nil
,
FormatError
(
err
)
}
}
...
@@ -109,8 +109,8 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {
...
@@ -109,8 +109,8 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {
if
v
:=
patch
.
Payload
;
v
!=
nil
{
if
v
:=
patch
.
Payload
;
v
!=
nil
{
set
,
args
=
append
(
set
,
"payload = ?"
),
append
(
args
,
*
v
)
set
,
args
=
append
(
set
,
"payload = ?"
),
append
(
args
,
*
v
)
}
}
if
v
:=
patch
.
PinnedT
s
;
v
!=
nil
{
if
v
:=
patch
.
RowStatu
s
;
v
!=
nil
{
set
,
args
=
append
(
set
,
"
pinned_t
s = ?"
),
append
(
args
,
*
v
)
set
,
args
=
append
(
set
,
"
row_statu
s = ?"
),
append
(
args
,
*
v
)
}
}
args
=
append
(
args
,
patch
.
Id
)
args
=
append
(
args
,
patch
.
Id
)
...
@@ -119,7 +119,7 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {
...
@@ -119,7 +119,7 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {
UPDATE shortcut
UPDATE shortcut
SET `
+
strings
.
Join
(
set
,
", "
)
+
`
SET `
+
strings
.
Join
(
set
,
", "
)
+
`
WHERE id = ?
WHERE id = ?
RETURNING id, title, payload, created_ts, updated_ts,
pinned_t
s
RETURNING id, title, payload, created_ts, updated_ts,
row_statu
s
`
,
args
...
)
`
,
args
...
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
FormatError
(
err
)
return
nil
,
FormatError
(
err
)
...
@@ -137,7 +137,7 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {
...
@@ -137,7 +137,7 @@ func patchShortcut(db *DB, patch *api.ShortcutPatch) (*api.Shortcut, error) {
&
shortcut
.
Payload
,
&
shortcut
.
Payload
,
&
shortcut
.
CreatedTs
,
&
shortcut
.
CreatedTs
,
&
shortcut
.
UpdatedTs
,
&
shortcut
.
UpdatedTs
,
&
shortcut
.
PinnedT
s
,
&
shortcut
.
RowStatu
s
,
);
err
!=
nil
{
);
err
!=
nil
{
return
nil
,
FormatError
(
err
)
return
nil
,
FormatError
(
err
)
}
}
...
@@ -166,7 +166,7 @@ func findShortcutList(db *DB, find *api.ShortcutFind) ([]*api.Shortcut, error) {
...
@@ -166,7 +166,7 @@ func findShortcutList(db *DB, find *api.ShortcutFind) ([]*api.Shortcut, error) {
creator_id,
creator_id,
created_ts,
created_ts,
updated_ts,
updated_ts,
pinned_t
s
row_statu
s
FROM shortcut
FROM shortcut
WHERE `
+
strings
.
Join
(
where
,
" AND "
),
WHERE `
+
strings
.
Join
(
where
,
" AND "
),
args
...
,
args
...
,
...
@@ -186,7 +186,7 @@ func findShortcutList(db *DB, find *api.ShortcutFind) ([]*api.Shortcut, error) {
...
@@ -186,7 +186,7 @@ func findShortcutList(db *DB, find *api.ShortcutFind) ([]*api.Shortcut, error) {
&
shortcut
.
CreatorId
,
&
shortcut
.
CreatorId
,
&
shortcut
.
CreatedTs
,
&
shortcut
.
CreatedTs
,
&
shortcut
.
UpdatedTs
,
&
shortcut
.
UpdatedTs
,
&
shortcut
.
PinnedT
s
,
&
shortcut
.
RowStatu
s
,
);
err
!=
nil
{
);
err
!=
nil
{
return
nil
,
FormatError
(
err
)
return
nil
,
FormatError
(
err
)
}
}
...
...
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