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
+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
}