fix: filter active in news
This commit is contained in:
@@ -5,15 +5,15 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (i *impl) GetAll(categoriesCode, tagCodes string) ([]newsdomain.News, error) {
|
||||
func (i *impl) GetAll(filter newsdomain.Filter) ([]newsdomain.News, error) {
|
||||
var err error
|
||||
|
||||
categories := []string{}
|
||||
tags := []string{}
|
||||
news := []newsdomain.News{}
|
||||
|
||||
tagCodeArr := strings.Split(tagCodes, " ")
|
||||
categoryCodeArr := strings.Split(categoriesCode, " ")
|
||||
tagCodeArr := strings.Split(filter.Tags, " ")
|
||||
categoryCodeArr := strings.Split(filter.Category, " ")
|
||||
|
||||
if len(tagCodeArr) > 0 && tagCodeArr[0] != "" {
|
||||
tags, err = i.tagRepo.GetIDsByCodes(tagCodeArr)
|
||||
@@ -37,9 +37,10 @@ func (i *impl) GetAll(categoriesCode, tagCodes string) ([]newsdomain.News, error
|
||||
}
|
||||
}
|
||||
|
||||
filter := newsdomain.NewsFilter{
|
||||
filterSpec := newsdomain.NewsFilter{
|
||||
Tags: tags,
|
||||
Category: categories,
|
||||
Active: filter.Active,
|
||||
}
|
||||
return i.newsRepo.GetAll(filter)
|
||||
return i.newsRepo.GetAll(filterSpec)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ type impl struct {
|
||||
}
|
||||
|
||||
type News interface {
|
||||
GetAll(string, string) ([]newsdomain.News, error)
|
||||
GetAll(filter newsdomain.Filter) ([]newsdomain.News, error)
|
||||
GetBySlug(string) (*newsdomain.News, error)
|
||||
Create(newsdomain.NewsReq, string) error
|
||||
Update(string, newsdomain.NewsUpdate) error
|
||||
|
||||
Reference in New Issue
Block a user