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
6f2ca6c8
Commit
6f2ca6c8
authored
Oct 20, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update find memo api
parent
952539f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
35 deletions
+42
-35
memo.go
api/v1/memo.go
+3
-2
memo.go
store/db/sqlite/memo.go
+36
-31
memo.go
store/memo.go
+1
-0
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+2
-2
No files found.
api/v1/memo.go
View file @
6f2ca6c8
...
...
@@ -471,8 +471,9 @@ func (s *APIV1Service) GetMemoStats(c echo.Context) error {
normalStatus
:=
store
.
Normal
hasParentFlag
:=
false
findMemoMessage
:=
&
store
.
FindMemo
{
RowStatus
:
&
normalStatus
,
HasParent
:
&
hasParentFlag
,
RowStatus
:
&
normalStatus
,
HasParent
:
&
hasParentFlag
,
ExcludeContent
:
true
,
}
if
creatorID
,
err
:=
util
.
ConvertStringToInt32
(
c
.
QueryParam
(
"creatorId"
));
err
==
nil
{
findMemoMessage
.
CreatorID
=
&
creatorID
...
...
store/db/sqlite/memo.go
View file @
6f2ca6c8
...
...
@@ -104,17 +104,23 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
}
orders
=
append
(
orders
,
"id DESC"
)
fields
:=
[]
string
{
`memo.id AS id`
,
`memo.creator_id AS creator_id`
,
`memo.created_ts AS created_ts`
,
`memo.updated_ts AS updated_ts`
,
`memo.row_status AS row_status`
,
`memo.visibility AS visibility`
,
}
if
!
find
.
ExcludeContent
{
fields
=
append
(
fields
,
`memo.content AS content`
)
}
query
:=
`
SELECT
memo.id AS id,
memo.creator_id AS creator_id,
memo.created_ts AS created_ts,
memo.updated_ts AS updated_ts,
memo.row_status AS row_status,
memo.content AS content,
memo.visibility AS visibility,
CASE WHEN memo_organizer.pinned = 1 THEN 1 ELSE 0 END AS pinned,
(
`
+
strings
.
Join
(
fields
,
", "
)
+
`
CASE WHEN mo.pinned = 1 THEN 1 ELSE 0 END AS pinned,
(
SELECT
related_memo_id
FROM
...
...
@@ -122,26 +128,25 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
WHERE
memo_relation.memo_id = memo.id AND memo_relation.type = 'COMMENT'
LIMIT 1
) AS parent_id,
GROUP_CONCAT(resource.id) AS resource_id_list,
(
) AS parent_id,
GROUP_CONCAT(resource.id) AS resource_id_list,
(
SELECT
GROUP_CONCAT(memo_
id || ':' || related_memo_id || ':' ||
type)
GROUP_CONCAT(memo_
relation.memo_id || ':' || memo_relation.related_memo_id || ':' || memo_relation.
type)
FROM
memo_relation
WHERE
memo_relation.memo_id = memo.id OR memo_relation.related_memo_id = memo.id
) AS relation_list
FROM
memo
LEFT JOIN
memo_organizer ON memo.id = memo_organizer.memo_id
LEFT JOIN
resource ON memo.id = resource.memo_id
WHERE `
+
strings
.
Join
(
where
,
" AND "
)
+
`
GROUP BY memo.id
ORDER BY `
+
strings
.
Join
(
orders
,
", "
)
+
`
`
) AS relation_list
FROM
memo
LEFT JOIN
memo_organizer mo ON memo.id = mo.memo_id
LEFT JOIN
resource ON memo.id = resource.memo_id
WHERE `
+
strings
.
Join
(
where
,
" AND "
)
+
`
GROUP BY memo.id
ORDER BY `
+
strings
.
Join
(
orders
,
", "
)
if
find
.
Limit
!=
nil
{
query
=
fmt
.
Sprintf
(
"%s LIMIT %d"
,
query
,
*
find
.
Limit
)
if
find
.
Offset
!=
nil
{
...
...
@@ -160,19 +165,19 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
var
memo
store
.
Memo
var
memoResourceIDList
sql
.
NullString
var
memoRelationList
sql
.
NullString
if
err
:=
rows
.
Scan
(
dests
:=
[]
any
{
&
memo
.
ID
,
&
memo
.
CreatorID
,
&
memo
.
CreatedTs
,
&
memo
.
UpdatedTs
,
&
memo
.
RowStatus
,
&
memo
.
Content
,
&
memo
.
Visibility
,
&
memo
.
Pinned
,
&
memo
.
ParentID
,
&
memoResourceIDList
,
&
memoRelationList
,
);
err
!=
nil
{
}
if
!
find
.
ExcludeContent
{
dests
=
append
(
dests
,
&
memo
.
Content
)
}
dests
=
append
(
dests
,
&
memo
.
Pinned
,
&
memo
.
ParentID
,
&
memoResourceIDList
,
&
memoRelationList
)
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
return
nil
,
err
}
...
...
store/memo.go
View file @
6f2ca6c8
...
...
@@ -64,6 +64,7 @@ type FindMemo struct {
VisibilityList
[]
Visibility
Pinned
*
bool
HasParent
*
bool
ExcludeContent
bool
// Pagination
Limit
*
int
...
...
web/src/pages/MemoDetail.tsx
View file @
6f2ca6c8
...
...
@@ -104,7 +104,7 @@ const MemoDetail = () => {
<>
<
section
className=
"relative top-0 w-full min-h-full overflow-x-hidden bg-zinc-100 dark:bg-zinc-900"
>
<
div
className=
"relative w-full h-auto mx-auto flex flex-col justify-start items-center bg-white dark:bg-zinc-700"
>
<
div
className=
"w-full flex flex-col justify-start items-center p
y
-8"
>
<
div
className=
"w-full flex flex-col justify-start items-center p
t-16 pb
-8"
>
<
UserAvatar
className=
"!w-20 h-auto mb-2 drop-shadow"
avatarUrl=
{
systemStatus
.
customizedProfile
.
logoUrl
}
/>
<
p
className=
"text-3xl text-black opacity-80 dark:text-gray-200"
>
{
systemStatus
.
customizedProfile
.
name
}
</
p
>
</
div
>
...
...
@@ -186,7 +186,7 @@ const MemoDetail = () => {
</
div
>
</
div
>
</
div
>
<
div
className=
"p
y-
6 w-full border-t dark:border-t-zinc-700"
>
<
div
className=
"p
t-8 pb-1
6 w-full border-t dark:border-t-zinc-700"
>
<
div
className=
"relative mx-auto flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4 gap-y-1"
>
{
comments
.
length
===
0
?
(
<
div
className=
"w-full flex flex-col justify-center items-center py-6 mb-2"
>
...
...
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