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
+52
View File
@@ -0,0 +1,52 @@
package active2023mod
import (
"fmt"
"91porn-server/common/db"
"91porn-server/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
)
const active2023PrizeTable = models.Active2023Prize // 用户中奖奖品详情表
func initPrizeIndex() {
coll := active2023PrizeColl(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]", active2023PrizeTable, err))
}
}
func active2023PrizeColl(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(active2023PrizeTable)
}
return t.Coll(active2023PrizeTable)
}
func InsertUserPrizes(t *db.MongoTool, ps *[]Prize) ([]primitive.ObjectID, error) {
if ps == nil || len(*ps) == 0 {
return nil, nil
}
result, err := active2023PrizeColl(t).InsertMany(ps)
if err != nil {
return nil, err
}
insertIDsLen := len(result.InsertedIDs)
if insertIDsLen == 0 {
return nil, nil
}
ids := make([]primitive.ObjectID, insertIDsLen)
for i := 0; i < insertIDsLen; i++ {
ids[i], _ = result.InsertedIDs[i].(primitive.ObjectID)
}
return ids, nil
}