mirror of
https://github.com/usememos/memos.git
synced 2025-02-01 01:58:14 +08:00
chore: update create memo with visibility
This commit is contained in:
parent
3517c6181d
commit
6053df050c
4 changed files with 13 additions and 7 deletions
|
@ -42,8 +42,8 @@ type MemoCreate struct {
|
||||||
CreatedTs *int64 `json:"createdTs"`
|
CreatedTs *int64 `json:"createdTs"`
|
||||||
|
|
||||||
// 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 {
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
1
web/src/types/modules/memo.d.ts
vendored
1
web/src/types/modules/memo.d.ts
vendored
|
@ -17,6 +17,7 @@ interface Memo {
|
||||||
|
|
||||||
interface MemoCreate {
|
interface MemoCreate {
|
||||||
content: string;
|
content: string;
|
||||||
|
visibility?: Visibility;
|
||||||
createdTs?: TimeStamp;
|
createdTs?: TimeStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue