Files
huangguo_server/models/v/proxyrecordmod/record.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

52 lines
1.0 KiB
Go

package proxyrecordmod
import (
"fmt"
"time"
"91porn-server/common/db"
"91porn-server/common/log"
"91porn-server/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
const table = models.InviteLog
// initIndex 设置index
func initIndex() {
coll := coll(nil)
many := []mongo.IndexModel{
{
Keys: bson.D{{Key: "uid", Value: 1}},
},
{
Keys: bson.D{{Key: "promotionCode", Value: 1}},
},
{
Keys: bson.D{{Key: "createdAt", Value: 1}},
},
}
if _, err := coll.CreateIndex(many); err != nil {
panic(fmt.Sprintf("%s model set index err ==>[%+v]", table, err))
}
}
func coll(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(table)
}
return t.Coll(table)
}
// InsertInvitationRecord 推广记录插入
func InsertInvitationRecord(iR *InvitationRecord) (err error) {
iR.CreatedAt = time.Now()
if _, err = coll(nil).InsertOne(iR); err != nil {
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "InsertInvitationRecord", table, "InsertOne", err))
return
}
return
}