init: hgmj server initial commit

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 16:50:13 +08:00
co-authored by Claude Opus 4.7
commit 625e89c15d
1870 changed files with 254090 additions and 0 deletions
+93
View File
@@ -0,0 +1,93 @@
package statvidmod
import (
"time"
"91jd-server/common/pageopt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
)
type Matcher = pageopt.Matcher
// SumDateMatch
type SumDateMatch struct {
SumDate *time.Time
}
func (s *SumDateMatch) New() Matcher {
return pageopt.NewAssignMatch("sumDate", s.SumDate)
}
// SumDateGTEAndLTMatch
type SumDateGTEAndLTMatch struct {
GTE *time.Time
LT *time.Time
}
func (s *SumDateGTEAndLTMatch) New() Matcher {
return pageopt.NewGTEAndLTMatch("sumDate", s.GTE, s.LT)
}
// PublisherIDMatch
type PublisherIDMatch struct {
UID *uint64
}
func (p *PublisherIDMatch) New() Matcher {
return pageopt.NewAssignMatch("publisherID", p.UID)
}
// PayCountGTMatch
type PayCountGTMatch struct {
GT *int64
}
func (p *PayCountGTMatch) New() Matcher {
return pageopt.NewGTMatch("payCount", p.GT)
}
// PlayCountGTMatch
type PlayCountGTMatch struct {
GT *int64
}
func (p *PlayCountGTMatch) New() Matcher {
return pageopt.NewGTMatch("playCount", p.GT)
}
// VidMatch
type VidMatch struct {
Vid *ObjectID
}
func (p *VidMatch) New() Matcher {
return pageopt.NewAssignMatch("vid", p.Vid)
}
// VidInMatch
type VidInMatch struct {
Vids []ObjectID
}
func (p *VidInMatch) New() Matcher {
return pageopt.NewInMatch("vid", p.Vids)
}
func List(sort bson.D, skip, limit int64, matchs ...Matcher) ([]Stat, error) {
opt := &options.FindOptions{}
if len(sort) != 0 {
opt.SetSort(sort)
}
opt.SetSkip(skip)
opt.SetLimit(limit)
filter := pageopt.MergeM(matchs)
list := make([]Stat, 0, limit)
return list, coll(nil).Find(&list, filter, opt)
}
func Count(matchs ...Matcher) (int64, error) {
filter := pageopt.MergeM(matchs)
return coll(nil).Count(filter)
}