Files
2026-10-08 16:50:13 +08:00

41 lines
905 B
Go

package active2023mod
import (
"fmt"
"91jd-server/common/db"
"91jd-server/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
const active2023LotteryTable = models.Active2023Lottery // 用户抽奖详情表
func initLotteryIndex() {
coll := active2023LotteryColl(nil)
many := []mongo.IndexModel{ //batch set indexes //value is the type 1 or -1
{
Keys: bson.D{{Key: "uid", Value: 1}},
},
}
if _, err := coll.CreateIndex(many); err != nil {
panic(fmt.Sprintf("%s model set index err ==>[%+v]", active2023LotteryTable, err))
}
}
func active2023LotteryColl(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(active2023LotteryTable)
}
return t.Coll(active2023LotteryTable)
}
func InsertUserLottery(t *db.MongoTool, ul *UserLottery) error {
if ul == nil {
return nil
}
_, err := active2023LotteryColl(t).InsertOne(ul)
return err
}