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
6053df05
Commit
6053df05
authored
Jul 15, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update create memo with visibility
parent
3517c618
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
7 deletions
+13
-7
memo.go
api/memo.go
+2
-2
memo.go
server/memo.go
+4
-2
memo.go
store/memo.go
+6
-3
memo.d.ts
web/src/types/modules/memo.d.ts
+1
-0
No files found.
api/memo.go
View file @
6053df05
...
@@ -43,7 +43,7 @@ type MemoCreate struct {
...
@@ -43,7 +43,7 @@ type MemoCreate struct {
// Domain specific fields
// Domain specific fields
Content
string
`json:"content"`
Content
string
`json:"content"`
Visibility
Visibility
`json:"visibility"`
Visibility
*
Visibility
`json:"visibility"`
}
}
type
MemoPatch
struct
{
type
MemoPatch
struct
{
...
...
server/memo.go
View file @
6053df05
...
@@ -22,8 +22,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -22,8 +22,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post memo request"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post memo request"
)
.
SetInternal
(
err
)
}
}
// TODO(steven): remove this line after frontend is ready
if
memoCreate
.
Visibility
==
nil
||
*
memoCreate
.
Visibility
==
""
{
memoCreate
.
Visibility
=
api
.
Privite
private
:=
api
.
Privite
memoCreate
.
Visibility
=
&
private
}
memo
,
err
:=
s
.
Store
.
CreateMemo
(
memoCreate
)
memo
,
err
:=
s
.
Store
.
CreateMemo
(
memoCreate
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
store/memo.go
View file @
6053df05
...
@@ -118,10 +118,13 @@ func (s *Store) DeleteMemo(delete *api.MemoDelete) error {
...
@@ -118,10 +118,13 @@ func (s *Store) DeleteMemo(delete *api.MemoDelete) error {
}
}
func
createMemoRaw
(
db
*
sql
.
DB
,
create
*
api
.
MemoCreate
)
(
*
memoRaw
,
error
)
{
func
createMemoRaw
(
db
*
sql
.
DB
,
create
*
api
.
MemoCreate
)
(
*
memoRaw
,
error
)
{
set
:=
[]
string
{
"creator_id"
,
"content"
,
"visibility"
}
set
:=
[]
string
{
"creator_id"
,
"content"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
}
placeholder
:=
[]
string
{
"?"
,
"?"
}
args
:=
[]
interface
{}{
create
.
CreatorID
,
create
.
Content
,
create
.
Visibility
}
args
:=
[]
interface
{}{
create
.
CreatorID
,
create
.
Content
}
if
v
:=
create
.
Visibility
;
v
!=
nil
{
set
,
placeholder
,
args
=
append
(
set
,
"visibility"
),
append
(
placeholder
,
"?"
),
append
(
args
,
*
v
)
}
if
v
:=
create
.
CreatedTs
;
v
!=
nil
{
if
v
:=
create
.
CreatedTs
;
v
!=
nil
{
set
,
placeholder
,
args
=
append
(
set
,
"created_ts"
),
append
(
placeholder
,
"?"
),
append
(
args
,
*
v
)
set
,
placeholder
,
args
=
append
(
set
,
"created_ts"
),
append
(
placeholder
,
"?"
),
append
(
args
,
*
v
)
}
}
...
...
web/src/types/modules/memo.d.ts
View file @
6053df05
...
@@ -17,6 +17,7 @@ interface Memo {
...
@@ -17,6 +17,7 @@ interface Memo {
interface
MemoCreate
{
interface
MemoCreate
{
content
:
string
;
content
:
string
;
visibility
?:
Visibility
;
createdTs
?:
TimeStamp
;
createdTs
?:
TimeStamp
;
}
}
...
...
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