作者 庄敏学

Merge branch 'dev' into test

@@ -31,6 +31,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS @@ -31,6 +31,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
31 WithOffsetLimit(req.Page, req.Size). 31 WithOffsetLimit(req.Page, req.Size).
32 WithKV("title", req.Title). 32 WithKV("title", req.Title).
33 WithKV("authorId", req.Author). 33 WithKV("authorId", req.Author).
  34 + WithKV("tags", req.Tags).
34 WithKV("beginCreatedAt", req.BeginTime). 35 WithKV("beginCreatedAt", req.BeginTime).
35 WithKV("endCreatedAt", req.EndTime) 36 WithKV("endCreatedAt", req.EndTime)
36 total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) 37 total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
@@ -3,6 +3,7 @@ package repository @@ -3,6 +3,7 @@ package repository
3 import ( 3 import (
4 "context" 4 "context"
5 "fmt" 5 "fmt"
  6 + "strings"
6 7
7 "github.com/pkg/errors" 8 "github.com/pkg/errors"
8 "github.com/tiptok/gocomm/pkg/cache" 9 "github.com/tiptok/gocomm/pkg/cache"
@@ -136,6 +137,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. @@ -136,6 +137,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
136 if v, ok := queryOptions["authorId"]; ok { 137 if v, ok := queryOptions["authorId"]; ok {
137 tx = tx.Where("author_id=?", v) 138 tx = tx.Where("author_id=?", v)
138 } 139 }
  140 + if v, ok := queryOptions["tags"]; ok && len(v.([]int64)) > 0 {
  141 + values := make([]string, 0)
  142 + for _, item := range v.([]int64) {
  143 + values = append(values, fmt.Sprintf("%v", item))
  144 + }
  145 + tx = tx.Where("tags @> ?", "["+strings.Join(values, ",")+"]")
  146 + }
139 if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { 147 if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
140 return dms, tx.Error 148 return dms, tx.Error
141 } 149 }