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
85dc29bf
Commit
85dc29bf
authored
Oct 03, 2022
by
steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add `linkedMemoAmount` to resource
parent
05e46ee4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
resource.go
api/resource.go
+3
-0
resource.go
server/resource.go
+10
-0
resource.go
store/resource.go
+1
-1
No files found.
api/resource.go
View file @
85dc29bf
...
@@ -13,6 +13,9 @@ type Resource struct {
...
@@ -13,6 +13,9 @@ type Resource struct {
Blob
[]
byte
`json:"-"`
Blob
[]
byte
`json:"-"`
Type
string
`json:"type"`
Type
string
`json:"type"`
Size
int64
`json:"size"`
Size
int64
`json:"size"`
// Related fields
LinkedMemoAmount
int
`json:"linkedMemoAmount"`
}
}
type
ResourceCreate
struct
{
type
ResourceCreate
struct
{
...
...
server/resource.go
View file @
85dc29bf
...
@@ -80,6 +80,16 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -80,6 +80,16 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch resource list"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch resource list"
)
.
SetInternal
(
err
)
}
}
for
_
,
resource
:=
range
list
{
memoResoureceList
,
err
:=
s
.
Store
.
FindMemoResourceList
(
ctx
,
&
api
.
MemoResourceFind
{
ResourceID
:
&
resource
.
ID
,
})
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find memo resource list"
)
.
SetInternal
(
err
)
}
resource
.
LinkedMemoAmount
=
len
(
memoResoureceList
)
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationJSONCharsetUTF8
)
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
composeResponse
(
list
));
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
c
.
Response
()
.
Writer
)
.
Encode
(
composeResponse
(
list
));
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to encode resource list response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to encode resource list response"
)
.
SetInternal
(
err
)
...
...
store/resource.go
View file @
85dc29bf
...
@@ -223,7 +223,7 @@ func findResourceList(ctx context.Context, tx *sql.Tx, find *api.ResourceFind) (
...
@@ -223,7 +223,7 @@ func findResourceList(ctx context.Context, tx *sql.Tx, find *api.ResourceFind) (
updated_ts
updated_ts
FROM resource
FROM resource
WHERE `
+
strings
.
Join
(
where
,
" AND "
)
+
`
WHERE `
+
strings
.
Join
(
where
,
" AND "
)
+
`
ORDER BY
created_ts
DESC
ORDER BY
id
DESC
`
`
rows
,
err
:=
tx
.
QueryContext
(
ctx
,
query
,
args
...
)
rows
,
err
:=
tx
.
QueryContext
(
ctx
,
query
,
args
...
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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