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
}
+31
View File
@@ -0,0 +1,31 @@
package welfarelgmod
import (
"time"
"91porn-server/common/db"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type WelFareType int64
const (
Fare_Vip WelFareType = iota //vip
Fare_Coin //金币
)
// 福利添加记录
type WelfareLog struct {
Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
Uid uint64 `json:"uid" bson:"uid"`
FareType WelFareType `json:"fareType" bson:"fareType"`
FareNum int64 `json:"fareNum" bson:"fareNum"`
DailyDate time.Time `json:"dailyDate" bson:"dailyDate"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
}
func Init() {
mdb = db.Init(table)
initIndex()
}