fix: group keyword filters to avoid OR bypass
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/field"
|
||||
"go.ipao.vip/gen/types"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -24,7 +25,7 @@ func (s *content) List(ctx context.Context, tenantID int64, filter *content_dto.
|
||||
// Filters
|
||||
if filter.Keyword != nil && *filter.Keyword != "" {
|
||||
keyword := "%" + *filter.Keyword + "%"
|
||||
q = q.Where(tbl.Title.Like(keyword)).Or(tbl.Description.Like(keyword))
|
||||
q = q.Where(field.Or(tbl.Title.Like(keyword), tbl.Description.Like(keyword)))
|
||||
}
|
||||
q = q.Where(tbl.Status.Eq(consts.ContentStatusPublished))
|
||||
if tenantID > 0 {
|
||||
|
||||
Reference in New Issue
Block a user