diff --git a/api/memo.go b/api/memo.go index cc4060cf..75dcd35c 100644 --- a/api/memo.go +++ b/api/memo.go @@ -42,7 +42,8 @@ type MemoFind struct { CreatorID *int `json:"creatorId"` // Domain specific fields - Pinned *bool + Pinned *bool + Tag *string } type MemoDelete struct { diff --git a/server/memo.go b/server/memo.go index 649ff72c..c03f3204 100644 --- a/server/memo.go +++ b/server/memo.go @@ -75,6 +75,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) { pinned := pinnedStr == "true" memoFind.Pinned = &pinned } + tag := c.QueryParam("tag") + if tag != "" { + memoFind.Tag = &tag + } list, err := s.Store.FindMemoList(memoFind) if err != nil { diff --git a/server/webhook.go b/server/webhook.go index acc0b13b..03fa6ad5 100644 --- a/server/webhook.go +++ b/server/webhook.go @@ -107,6 +107,15 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) { if rowStatus != "" { memoFind.RowStatus = &rowStatus } + pinnedStr := c.QueryParam("pinned") + if pinnedStr != "" { + pinned := pinnedStr == "true" + memoFind.Pinned = &pinned + } + tag := c.QueryParam("tag") + if tag != "" { + memoFind.Tag = &tag + } list, err := s.Store.FindMemoList(memoFind) if err != nil { diff --git a/store/memo.go b/store/memo.go index 9a626487..76cdeb3e 100644 --- a/store/memo.go +++ b/store/memo.go @@ -209,6 +209,9 @@ func findMemoRawList(db *sql.DB, find *api.MemoFind) ([]*memoRaw, error) { if v := find.Pinned; v != nil { where = append(where, "id in (SELECT memo_id FROM memo_organizer WHERE pinned = 1 AND user_id = memo.creator_id )") } + if v := find.Tag; v != nil { + where, args = append(where, "content LIKE ?"), append(args, "%#"+*v+"%") + } rows, err := db.Query(` SELECT