chore: find memo by tag (#74)

This commit is contained in:
STEVEN 2022-06-14 23:09:03 +08:00 committed by GitHub
parent 8df0711f80
commit 164873b344
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 1 deletions

View file

@ -43,6 +43,7 @@ type MemoFind struct {
// Domain specific fields
Pinned *bool
Tag *string
}
type MemoDelete struct {

View file

@ -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 {

View file

@ -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 {

View file

@ -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