64 lines
1.2 KiB
Go
64 lines
1.2 KiB
Go
package tonerecomod
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"91porn-server/common/log"
|
|
"91porn-server/models"
|
|
)
|
|
|
|
// OffiRecomPages OffiRecomPages
|
|
func OffiRecomPages(sort D, skip int64, limit int64) (page OffiRecomPage, err error) {
|
|
pipeline := []M{
|
|
{
|
|
"$facet": M{
|
|
"total": A{M{"$count": "total"}},
|
|
"list": A{
|
|
M{"$sort": sort},
|
|
M{"$skip": skip},
|
|
M{"$limit": limit},
|
|
M{
|
|
"$lookup": M{
|
|
"from": models.VideoInfo,
|
|
"localField": "vid",
|
|
"foreignField": "_id",
|
|
"as": "video_info",
|
|
},
|
|
},
|
|
M{
|
|
"$unwind": "$video_info",
|
|
},
|
|
M{
|
|
"$set": M{
|
|
"video_info.sortKey": "$sortKey",
|
|
"video_info.enable": "$enable",
|
|
},
|
|
},
|
|
M{
|
|
"$replaceWith": "$video_info",
|
|
},
|
|
M{
|
|
"$lookup": M{
|
|
"from": models.Tag,
|
|
"localField": "tags",
|
|
"foreignField": "_id",
|
|
"as": "tags",
|
|
},
|
|
},
|
|
}},
|
|
},
|
|
{
|
|
"$project": M{
|
|
"total": M{"$arrayElemAt": A{"$total.total", 0}},
|
|
"list": 1,
|
|
},
|
|
},
|
|
}
|
|
coll := mdb.Coll(models.ToneRecom)
|
|
if err = coll.AggregateDecode(&page, pipeline); err != nil {
|
|
log.ZapLog.Error(fmt.Sprintf("coll:%s Page error:%+v:", models.ToneRecom, err))
|
|
return
|
|
}
|
|
return
|
|
}
|