Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
package newactivity
import (
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
)
func AddWinRecord(req WinRecords) error {
_, err := collWin(nil).UpsertOne(bson.M{
"date": req.Date,
"modelId": req.ModelId,
}, bson.M{"$set": req})
return err
}
func WinRecordsByDate(date time.Time) ([]WinRecords, error) {
list := make([]WinRecords, 0)
return list, collWin(nil).Find(&list, bson.M{"date": date})
}
func WinRecordPage(req WinRcdPageReq) (res WinRcdPageRes, err error) {
conf := bson.M{}
if req.ModelId != nil {
conf["modelId"] = req.ModelId
}
if req.UserId != nil {
conf["userId"] = req.UserId
}
if req.UserName != nil {
conf["userName"] = bson.M{"$regex": req.UserName}
}
if !req.Date.IsZero() {
conf["date"] = req.Date
}
res = WinRcdPageRes{}
opts := options.Find().SetSort(bson.D{{Key: "createdAt", Value: -1}})
opts.SetSkip((req.Page - 1) * req.PageSize)
opts.SetLimit(req.PageSize)
if err = collWin(nil).Find(&res.Data, conf, opts); err != nil {
return
}
res.Total, err = collWin(nil).Count(conf)
return
}