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
+54
View File
@@ -0,0 +1,54 @@
package welfarelgmod
import (
"fmt"
"91porn-server/common/db"
"91porn-server/common/log"
"91porn-server/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var mdb *db.MongoDB
const table = models.WelfareLog
func coll(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(table)
}
return t.Coll(table)
}
// initIndex 初始化索引
func initIndex() {
many := []mongo.IndexModel{
{
Keys: bson.D{{Key: "uid", Value: -1}, {Key: "fareType", Value: -1}},
Options: options.Index().SetUnique(true),
}, {
Keys: bson.D{{Key: "createdAt", Value: -1}},
},
}
if _, err := coll(nil).CreateIndex(many); err != nil {
panic(fmt.Sprintf("%s model set index err ==>[%+v]", table, err))
}
}
// InsertWelFareLog InsertWelFareLog
func InsertWelFareLog(p WelfareLog) error {
_, err := coll(nil).InsertOne(&p)
return err
}
// FindWelFareByUid 查询
func FindWelFareByUid(uid uint64) (pr *WelfareLog, err error) {
if err = coll(nil).FindOne(&pr, bson.M{"uid": uid}); err != nil {
log.Error("FindWelFareByUid error", log.E(err))
return
}
return
}