58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package vidtonesearcher
|
|
|
|
import (
|
|
"91porn-server/app/service/searcher"
|
|
"91porn-server/models/v/tonerecomod"
|
|
"91porn-server/models/v/vidmod"
|
|
)
|
|
|
|
// mostCommentsSearcher mostCommentsSearcher
|
|
type mostCommentsSearcher struct {
|
|
uid uint64
|
|
}
|
|
|
|
// newMostCommentsSearcher newMostCommentsSearcher
|
|
func newMostCommentsSearcher(uid uint64) searcher.Searcher {
|
|
return &mostCommentsSearcher{
|
|
uid: uid,
|
|
}
|
|
}
|
|
|
|
// Search Search
|
|
func (g *mostCommentsSearcher) Search(unuse searcher.KeyWorder, opt searcher.Opter) (result searcher.Resulter, err error) {
|
|
limit := opt.Limit()
|
|
limitEx1 := limit + 1
|
|
vidList, err := vidmod.VIDListSortByFakeCommentCount(opt.Skip(), limitEx1)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if len(vidList) == 0 {
|
|
return &Result{
|
|
&Resp{
|
|
Theme: tonerecomod.MostComments,
|
|
List: []VideoRes{},
|
|
PlayCount: &zero,
|
|
HasNext: false,
|
|
},
|
|
}, nil
|
|
}
|
|
hasNext := false
|
|
if len(vidList) > int(limit) {
|
|
hasNext = true
|
|
vidList = vidList[:opt.Limit()]
|
|
}
|
|
videoResList, err := searcher.GetVideoResList(g.uid, vidList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mostCommentsPlayCount := GetToneValue().MostCommentsPlayCount
|
|
return &Result{
|
|
&Resp{
|
|
List: videoResList,
|
|
Theme: tonerecomod.MostComments,
|
|
PlayCount: &mostCommentsPlayCount,
|
|
HasNext: hasNext,
|
|
},
|
|
}, nil
|
|
}
|