mirror of
https://github.com/usememos/memos.git
synced 2025-01-31 17:48:12 +08:00
chore: find memo by tag (#74)
This commit is contained in:
parent
8df0711f80
commit
164873b344
4 changed files with 18 additions and 1 deletions
|
@ -42,7 +42,8 @@ type MemoFind struct {
|
|||
CreatorID *int `json:"creatorId"`
|
||||
|
||||
// Domain specific fields
|
||||
Pinned *bool
|
||||
Pinned *bool
|
||||
Tag *string
|
||||
}
|
||||
|
||||
type MemoDelete struct {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue