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
d8a05281
Commit
d8a05281
authored
Dec 18, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak variable names
parent
16fb5fae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
19 deletions
+18
-19
memo.go
api/v1/memo.go
+8
-8
user.go
api/v1/user.go
+2
-3
memo.go
store/db/mysql/memo.go
+4
-4
memo.go
store/db/sqlite/memo.go
+4
-4
No files found.
api/v1/memo.go
View file @
d8a05281
...
@@ -435,34 +435,34 @@ func (s *APIV1Service) CreateMemo(c echo.Context) error {
...
@@ -435,34 +435,34 @@ func (s *APIV1Service) CreateMemo(c echo.Context) error {
// - creatorUsername is listed at ./web/src/helpers/api.ts:82, but it's not present here
// - creatorUsername is listed at ./web/src/helpers/api.ts:82, but it's not present here
func
(
s
*
APIV1Service
)
GetAllMemos
(
c
echo
.
Context
)
error
{
func
(
s
*
APIV1Service
)
GetAllMemos
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
findMemoMessage
:=
&
store
.
FindMemo
{}
memoFind
:=
&
store
.
FindMemo
{}
_
,
ok
:=
c
.
Get
(
userIDContextKey
)
.
(
int32
)
_
,
ok
:=
c
.
Get
(
userIDContextKey
)
.
(
int32
)
if
!
ok
{
if
!
ok
{
findMemoMessage
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
}
else
{
}
else
{
findMemoMessage
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
,
store
.
Protected
}
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
,
store
.
Protected
}
}
}
if
limit
,
err
:=
strconv
.
Atoi
(
c
.
QueryParam
(
"limit"
));
err
==
nil
{
if
limit
,
err
:=
strconv
.
Atoi
(
c
.
QueryParam
(
"limit"
));
err
==
nil
{
findMemoMessage
.
Limit
=
&
limit
memoFind
.
Limit
=
&
limit
}
}
if
offset
,
err
:=
strconv
.
Atoi
(
c
.
QueryParam
(
"offset"
));
err
==
nil
{
if
offset
,
err
:=
strconv
.
Atoi
(
c
.
QueryParam
(
"offset"
));
err
==
nil
{
findMemoMessage
.
Offset
=
&
offset
memoFind
.
Offset
=
&
offset
}
}
// Only fetch normal status memos.
// Only fetch normal status memos.
normalStatus
:=
store
.
Normal
normalStatus
:=
store
.
Normal
findMemoMessage
.
RowStatus
=
&
normalStatus
memoFind
.
RowStatus
=
&
normalStatus
memoDisplayWithUpdatedTs
,
err
:=
s
.
getMemoDisplayWithUpdatedTsSettingValue
(
ctx
)
memoDisplayWithUpdatedTs
,
err
:=
s
.
getMemoDisplayWithUpdatedTsSettingValue
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to get memo display with updated ts setting value"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to get memo display with updated ts setting value"
)
.
SetInternal
(
err
)
}
}
if
memoDisplayWithUpdatedTs
{
if
memoDisplayWithUpdatedTs
{
findMemoMessage
.
OrderByUpdatedTs
=
true
memoFind
.
OrderByUpdatedTs
=
true
}
}
list
,
err
:=
s
.
Store
.
ListMemos
(
ctx
,
findMemoMessage
)
list
,
err
:=
s
.
Store
.
ListMemos
(
ctx
,
memoFind
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch all memo list"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch all memo list"
)
.
SetInternal
(
err
)
}
}
...
...
api/v1/user.go
View file @
d8a05281
...
@@ -313,10 +313,9 @@ func (s *APIV1Service) DeleteUser(c echo.Context) error {
...
@@ -313,10 +313,9 @@ func (s *APIV1Service) DeleteUser(c echo.Context) error {
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
fmt
.
Sprintf
(
"ID is not a number: %s"
,
c
.
Param
(
"id"
)))
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
fmt
.
Sprintf
(
"ID is not a number: %s"
,
c
.
Param
(
"id"
)))
.
SetInternal
(
err
)
}
}
userDelete
:=
&
store
.
DeleteUser
{
if
err
:=
s
.
Store
.
DeleteUser
(
ctx
,
&
store
.
DeleteUser
{
ID
:
userID
,
ID
:
userID
,
}
});
err
!=
nil
{
if
err
:=
s
.
Store
.
DeleteUser
(
ctx
,
userDelete
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to delete user"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to delete user"
)
.
SetInternal
(
err
)
}
}
return
c
.
JSON
(
http
.
StatusOK
,
true
)
return
c
.
JSON
(
http
.
StatusOK
,
true
)
...
...
store/db/mysql/memo.go
View file @
d8a05281
...
@@ -64,12 +64,12 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -64,12 +64,12 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
}
}
}
}
if
v
:=
find
.
VisibilityList
;
len
(
v
)
!=
0
{
if
v
:=
find
.
VisibilityList
;
len
(
v
)
!=
0
{
list
:=
[]
string
{}
placeholder
:=
[]
string
{}
for
_
,
visibility
:=
range
v
{
for
_
,
visibility
:=
range
v
{
list
=
append
(
list
,
"?"
)
placeholder
=
append
(
placeholder
,
"?"
)
args
=
append
(
args
,
visibility
)
args
=
append
(
args
,
visibility
.
String
()
)
}
}
where
=
append
(
where
,
fmt
.
Sprintf
(
"`memo`.`visibility` in (%s)"
,
strings
.
Join
(
list
,
","
)))
where
=
append
(
where
,
fmt
.
Sprintf
(
"`memo`.`visibility` in (%s)"
,
strings
.
Join
(
placeholder
,
","
)))
}
}
orders
:=
[]
string
{}
orders
:=
[]
string
{}
if
find
.
OrderByPinned
{
if
find
.
OrderByPinned
{
...
...
store/db/sqlite/memo.go
View file @
d8a05281
...
@@ -51,12 +51,12 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -51,12 +51,12 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
}
}
}
}
if
v
:=
find
.
VisibilityList
;
len
(
v
)
!=
0
{
if
v
:=
find
.
VisibilityList
;
len
(
v
)
!=
0
{
list
:=
[]
string
{}
placeholder
:=
[]
string
{}
for
_
,
visibility
:=
range
v
{
for
_
,
visibility
:=
range
v
{
list
=
append
(
list
,
fmt
.
Sprintf
(
"$%d"
,
len
(
args
)
+
1
)
)
placeholder
=
append
(
placeholder
,
"?"
)
args
=
append
(
args
,
visibility
)
args
=
append
(
args
,
visibility
.
String
()
)
}
}
where
=
append
(
where
,
fmt
.
Sprintf
(
"memo.visibility in (%s)"
,
strings
.
Join
(
list
,
","
)))
where
=
append
(
where
,
fmt
.
Sprintf
(
"memo.visibility in (%s)"
,
strings
.
Join
(
placeholder
,
","
)))
}
}
if
v
:=
find
.
Pinned
;
v
!=
nil
{
if
v
:=
find
.
Pinned
;
v
!=
nil
{
where
=
append
(
where
,
"memo_organizer.pinned = 1"
)
where
=
append
(
where
,
"memo_organizer.pinned = 1"
)
...
...
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