Files
huangguo_server/models/v/authoritymod/page.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

41 lines
777 B
Go

package authoritymod
import (
"fmt"
"91porn-server/common/log"
)
// AuthorPage AuthorPage
type AuthorPage struct {
Total int `json:"total" bson:"total"`
List []AuthorityDoc `json:"list" bson:"list"`
}
// AuthorPages AuthorPages
func AuthorPages(skip int64, limit int64) (page AuthorPage, err error) {
pipeline := []M{
M{
"$facet": M{
"total": A{M{"$count": "total"}},
"list": A{
M{"$sort": M{"role": 1}},
M{"$skip": skip},
M{"$limit": limit},
},
},
},
M{
"$project": M{
"total": M{"$arrayElemAt": A{"$total.total", 0}},
"list": 1,
},
},
}
if err = coll(nil).AggregateDecode(&page, pipeline); err != nil {
log.ZapLog.Error(fmt.Sprintf("coll:%s Page error:%+v:", table, err))
return
}
return
}