85 lines
1.7 KiB
Go
85 lines
1.7 KiB
Go
package payvidlgmod
|
|
|
|
import (
|
|
"91porn-server/common/log"
|
|
"91porn-server/common/pageopt"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
)
|
|
|
|
type Matcher = pageopt.Matcher
|
|
|
|
// DistrictCodeMatch
|
|
type DistrictCodeMatch struct {
|
|
DistrictCode *string
|
|
}
|
|
|
|
func (s *DistrictCodeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("districtCode", s.DistrictCode)
|
|
}
|
|
|
|
// IsDirectMatch
|
|
type IsDirectMatch struct {
|
|
IsDirect *bool
|
|
}
|
|
|
|
func (b *IsDirectMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("isDirect", b.IsDirect)
|
|
}
|
|
|
|
// PromSeqeMatch
|
|
type PromSeqeMatch struct {
|
|
Seqe *string
|
|
}
|
|
|
|
func (d *PromSeqeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("promSeqe", d.Seqe)
|
|
}
|
|
|
|
// SysTypeMatch
|
|
type SysTypeMatch struct {
|
|
SysType *string
|
|
}
|
|
|
|
func (d *SysTypeMatch) New() Matcher {
|
|
return pageopt.NewAssignMatch("sysType", d.SysType)
|
|
}
|
|
|
|
// CreatedAtGTEAndLTMatch
|
|
type CreatedAtGTEAndLTMatch = pageopt.CreatedAtGTEAndLTMatch
|
|
|
|
type Sort = bson.D
|
|
|
|
var Sort_CreatedAt_n1 = Sort{{Key: "createdAt", Value: -1}}
|
|
|
|
func List(sort Sort, skip, limit *int64, matchers ...Matcher) ([]Pay4VidLog, error) {
|
|
filter := pageopt.MergeM(matchers)
|
|
opt := (&options.FindOptions{})
|
|
if len(sort) != 0 {
|
|
opt.SetSort(sort)
|
|
}
|
|
if skip != nil {
|
|
opt.SetSkip(*skip)
|
|
}
|
|
if limit != nil {
|
|
opt.SetLimit(*limit)
|
|
}
|
|
list := []Pay4VidLog{}
|
|
if err := coll(nil).Find(&list, filter, opt); err != nil {
|
|
log.Error("payvidlgmod List error", log.E(err))
|
|
return nil, err
|
|
}
|
|
return list, nil
|
|
}
|
|
|
|
func Count(matchers ...Matcher) (int64, error) {
|
|
filter := pageopt.MergeM(matchers)
|
|
count, err := coll(nil).Count(filter)
|
|
if err != nil {
|
|
log.Error("payvidlgmod Count error", log.E(err))
|
|
return 0, err
|
|
}
|
|
return count, nil
|
|
}
|