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