@@ -0,0 +1,73 @@
|
||||
package vidpcountsearcher
|
||||
|
||||
import (
|
||||
"91porn-server/app/service/searcher"
|
||||
"91porn-server/models/v/vidmod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type ObjectID = primitive.ObjectID
|
||||
|
||||
// VidPlayCountSearcher VidPlayCountSearcher
|
||||
type VidPlayCountSearcher struct {
|
||||
uid uint64
|
||||
typ ResultType
|
||||
}
|
||||
|
||||
// NewVidPlayCountSearcher NewVidPlayCountSearcher
|
||||
func NewVidPlayCountSearcher(uid uint64) searcher.Searcher {
|
||||
return &VidPlayCountSearcher{
|
||||
uid: uid,
|
||||
typ: Video,
|
||||
}
|
||||
}
|
||||
|
||||
// NewRichVidPlayCountSearcher NewRichVidPlayCountSearcher
|
||||
func NewRichVidPlayCountSearcher(uid uint64) searcher.Searcher {
|
||||
return &VidPlayCountSearcher{
|
||||
uid: uid,
|
||||
typ: RichVido,
|
||||
}
|
||||
}
|
||||
|
||||
// Search Search
|
||||
func (v *VidPlayCountSearcher) Search(unuse searcher.KeyWorder, opt searcher.Opter) (result searcher.Resulter, err error) {
|
||||
limitEx := opt.Limit() + 1
|
||||
vidList, err := vidmod.VIDListByFakePlayCount(opt.Skip(), limitEx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(vidList) == 0 {
|
||||
return &Result{
|
||||
typ: v.typ,
|
||||
dat: []VideoRes{},
|
||||
richDat: []RichVidRes{},
|
||||
}, nil
|
||||
}
|
||||
hasNext := false
|
||||
if len(vidList) > int(opt.Limit()) {
|
||||
hasNext = true
|
||||
vidList = vidList[:opt.Limit()]
|
||||
}
|
||||
if v.typ == Video {
|
||||
videoResList, err := searcher.GetVideoResList(v.uid, vidList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Result{
|
||||
dat: videoResList,
|
||||
typ: v.typ,
|
||||
hasNext: hasNext,
|
||||
}, nil
|
||||
}
|
||||
richVideoResList, err := searcher.GetRichVideoResList(v.uid, vidList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Result{
|
||||
richDat: richVideoResList,
|
||||
typ: v.typ,
|
||||
hasNext: hasNext,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user