@@ -0,0 +1,218 @@
|
||||
package usermod
|
||||
|
||||
import (
|
||||
"91porn-server/common/pageopt"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type Matcher = pageopt.Matcher
|
||||
|
||||
const districtCode = "districtCode"
|
||||
|
||||
// DistrictCodeGtMatch
|
||||
type DistrictCodeGtMatch struct {
|
||||
GT *string
|
||||
}
|
||||
|
||||
func (s *DistrictCodeGtMatch) New() Matcher {
|
||||
return pageopt.NewGTMatch(districtCode, s.GT)
|
||||
}
|
||||
|
||||
// DistrictCodeMatch
|
||||
type DistrictCodeMatch struct {
|
||||
DistrictCode *string
|
||||
}
|
||||
|
||||
func (s *DistrictCodeMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch(districtCode, s.DistrictCode)
|
||||
}
|
||||
|
||||
// DistrictCodeINMatch
|
||||
type DistrictCodeINMatch struct {
|
||||
DistrictCodeList []string
|
||||
}
|
||||
|
||||
func (d *DistrictCodeINMatch) New() Matcher {
|
||||
return pageopt.NewInMatch(districtCode, d.DistrictCodeList)
|
||||
}
|
||||
|
||||
// PromSeqeMatch
|
||||
type PromSeqeMatch struct {
|
||||
Seqe *string
|
||||
}
|
||||
|
||||
func (d *PromSeqeMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("promSeqe", d.Seqe)
|
||||
}
|
||||
|
||||
// SysTypeMatch
|
||||
type SysTypeMatch struct {
|
||||
SysType *string
|
||||
}
|
||||
|
||||
func (s *SysTypeMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("sysType", s.SysType)
|
||||
}
|
||||
|
||||
// IsDirectMatch
|
||||
type IsDirectMatch struct {
|
||||
IsDirect *bool
|
||||
}
|
||||
|
||||
func (b *IsDirectMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("isDirect", b.IsDirect)
|
||||
}
|
||||
|
||||
// DevIDRegexMatch
|
||||
type DevIDRegexMatch struct {
|
||||
DevID *string
|
||||
}
|
||||
|
||||
func (d *DevIDRegexMatch) New() Matcher {
|
||||
return pageopt.NewRegexMatch("devID", d.DevID, "i")
|
||||
}
|
||||
|
||||
// VipLevelMatch
|
||||
type VipLevelMatch struct {
|
||||
VipLevel *int
|
||||
}
|
||||
|
||||
func (v *VipLevelMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("vipLevel", v.VipLevel)
|
||||
}
|
||||
|
||||
// NameRegexMatch
|
||||
type NameRegexMatch struct {
|
||||
Name *string
|
||||
}
|
||||
|
||||
func (n *NameRegexMatch) New() Matcher {
|
||||
return pageopt.NewRegexMatch("name", n.Name, "i")
|
||||
}
|
||||
|
||||
// MobileMatch
|
||||
type MobileMatch struct {
|
||||
Mobile *string
|
||||
}
|
||||
|
||||
func (m *MobileMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("mobile", m.Mobile)
|
||||
}
|
||||
|
||||
// PromotionCodeMatch
|
||||
type PromotionCodeMatch struct {
|
||||
PromotionCode *string
|
||||
}
|
||||
|
||||
func (p *PromotionCodeMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("promotionCode", p.PromotionCode)
|
||||
}
|
||||
|
||||
// HasPromotionCodeMatch
|
||||
type HasPromotionCodeMatch struct {
|
||||
IsExisted *bool
|
||||
}
|
||||
|
||||
func (h *HasPromotionCodeMatch) New() Matcher {
|
||||
return pageopt.NewExistsMatch("promotionCode", h.IsExisted)
|
||||
}
|
||||
|
||||
// AutoFollowMatch
|
||||
type AutoFollowMatch struct {
|
||||
AutoFollow *bool
|
||||
}
|
||||
|
||||
func (l *AutoFollowMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("autoFollow", l.AutoFollow)
|
||||
}
|
||||
|
||||
// LockedMatch
|
||||
type LockedMatch struct {
|
||||
Locked *bool
|
||||
}
|
||||
|
||||
func (l *LockedMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("hasLocked", l.Locked)
|
||||
}
|
||||
|
||||
// BannedMatch
|
||||
type BannedMatch struct {
|
||||
Banned *bool
|
||||
}
|
||||
|
||||
func (b *BannedMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("hasBanned", b.Banned)
|
||||
}
|
||||
|
||||
// CanUploadMatch
|
||||
type ForbidUploadMatch struct {
|
||||
ForbidUpload *bool
|
||||
}
|
||||
|
||||
func (c *ForbidUploadMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("forbidUpload", c.ForbidUpload)
|
||||
}
|
||||
|
||||
// TrueScoreGTEMatch
|
||||
type TrueScoreGTEMatch struct {
|
||||
GTE *int64
|
||||
}
|
||||
|
||||
func (b *TrueScoreGTEMatch) New() Matcher {
|
||||
return pageopt.NewGTEMatch("trueScore", b.GTE)
|
||||
}
|
||||
|
||||
// TrueScoreMatch
|
||||
type TrueScoreMatch struct {
|
||||
TrueScore *int64
|
||||
}
|
||||
|
||||
func (b *TrueScoreMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("trueScore", b.TrueScore)
|
||||
}
|
||||
|
||||
type RegisterIpMatch struct {
|
||||
RegisterIp *string
|
||||
}
|
||||
|
||||
func (b *RegisterIpMatch) New() Matcher {
|
||||
return pageopt.NewAssignMatch("registerIP", b.RegisterIp)
|
||||
}
|
||||
|
||||
// CreatedAtGTEAndLTMatch
|
||||
type CreatedAtGTEAndLTMatch = pageopt.CreatedAtGTEAndLTMatch
|
||||
|
||||
// UIDInMatch
|
||||
type UIDInMatch = pageopt.UIDInMatch
|
||||
|
||||
// UIDMatch
|
||||
type UIDMatch = pageopt.UIDMatch
|
||||
|
||||
type Sort = bson.D
|
||||
|
||||
var Sort_CreatedAt_n1 = Sort{{Key: "createdAt", Value: -1}}
|
||||
|
||||
type UserSlice []User
|
||||
|
||||
func List(sort bson.D, skip, limit *int64, matchs ...Matcher) (UserSlice, error) {
|
||||
opt := (&options.FindOptions{})
|
||||
if len(sort) != 0 {
|
||||
opt.SetSort(sort)
|
||||
}
|
||||
if skip != nil {
|
||||
opt.SetSkip(*skip)
|
||||
}
|
||||
if limit != nil {
|
||||
opt.SetLimit(*limit)
|
||||
}
|
||||
filter := pageopt.MergeM(matchs)
|
||||
userList := UserSlice{}
|
||||
return userList, coll(nil).Find(&userList, filter, opt)
|
||||
}
|
||||
|
||||
func Count(matchs ...Matcher) (int64, error) {
|
||||
filter := pageopt.MergeM(matchs)
|
||||
return coll(nil).Count(filter)
|
||||
}
|
||||
Reference in New Issue
Block a user