作者 庄敏学

Merge branch 'dev' into test

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