refactor: memo store (#1741)

This commit is contained in:
boojack
2023-05-25 21:50:37 +08:00
committed by GitHub
parent 43819b021e
commit ea728d232d
16 changed files with 528 additions and 543 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
"github.com/usememos/memos/api"
"github.com/usememos/memos/common"
"github.com/usememos/memos/store"
"golang.org/x/exp/slices"
"github.com/labstack/echo/v4"
@@ -71,14 +72,14 @@ func (s *Server) registerTagRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusBadRequest, "Missing user session")
}
contentSearch := "#"
normalRowStatus := api.Normal
memoFind := api.MemoFind{
normalRowStatus := store.Normal
memoFind := &store.FindMemoMessage{
CreatorID: &userID,
ContentSearch: &contentSearch,
RowStatus: &normalRowStatus,
}
memoList, err := s.Store.FindMemoList(ctx, &memoFind)
memoMessageList, err := s.Store.ListMemos(ctx, memoFind)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find memo list").SetInternal(err)
}
@@ -96,7 +97,7 @@ func (s *Server) registerTagRoutes(g *echo.Group) {
}
tagMapSet := make(map[string]bool)
for _, memo := range memoList {
for _, memo := range memoMessageList {
for _, tag := range findTagListFromMemoContent(memo.Content) {
if !slices.Contains(tagNameList, tag) {
tagMapSet[tag] = true