上传埋点校验查询接口跨服使用优化
This commit is contained in:
parent
559b96b287
commit
12315a53c7
@ -8,6 +8,7 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/redis"
|
"go_dreamfactory/lego/sys/redis"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
@ -62,21 +63,48 @@ func (this *modelBuried) userlock(uid string) (result *redis.RedisMutex, err err
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新埋点数据到db中
|
//更新埋点数据到db中
|
||||||
// func (this *modelBuried) getburiedModel(uid string) (model *buriedModel, err error) {
|
func (this *modelBuried) getburiedModel(uid string) (model *buriedModel, err error) {
|
||||||
// var m *db.DBModel
|
var m *db.DBModel
|
||||||
// if db.IsCross() {
|
if db.IsCross() {
|
||||||
// if m, err = this.module.GetDBModelByUid(uid, this.TableName); err != nil {
|
if m, err = this.module.GetDBModelByUid(uid, this.TableName); err != nil {
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
// model = &buriedModel{module: this.module, model: m}
|
model = &buriedModel{module: this.module, model: m}
|
||||||
// } else {
|
} else {
|
||||||
// model = &buriedModel{module: this.module, model: this.DBModel}
|
model = &buriedModel{module: this.module, model: this.DBModel}
|
||||||
// }
|
}
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //埋点专属模型 会封装特殊的数据转换接口
|
//埋点专属模型 会封装特殊的数据转换接口
|
||||||
// type buriedModel struct {
|
type buriedModel struct {
|
||||||
// module *Buried
|
module *Buried
|
||||||
// model *db.DBModel
|
model *db.DBModel
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
//获取用户全部的埋点数据
|
||||||
|
func (this *buriedModel) getUserBurieds(uid string) (results *pb.DBBuried, err error) {
|
||||||
|
results = &pb.DBBuried{}
|
||||||
|
if err = this.model.Get(uid, results); err != nil && err != mgo.MongodbNil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err == mgo.MongodbNil {
|
||||||
|
err = nil
|
||||||
|
results = &pb.DBBuried{
|
||||||
|
Id: primitive.NewObjectID().Hex(),
|
||||||
|
Uid: uid,
|
||||||
|
Items: make(map[int32]*pb.DBBuriedItem),
|
||||||
|
}
|
||||||
|
err = this.model.Add(uid, results)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新用户数据
|
||||||
|
func (this *buriedModel) updateUserBurieds(uid string, data *pb.DBBuried) (err error) {
|
||||||
|
err = this.model.Change(uid, map[string]interface{}{
|
||||||
|
"items": data.Items,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -72,10 +72,13 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (err error) {
|
|||||||
var (
|
var (
|
||||||
conf *cfg.GameBuriedCondiData
|
conf *cfg.GameBuriedCondiData
|
||||||
bdatas *pb.DBBuried
|
bdatas *pb.DBBuried
|
||||||
|
model *buriedModel
|
||||||
chanage bool
|
chanage bool
|
||||||
)
|
)
|
||||||
|
if model, err = this.modelBuried.getburiedModel(uid); err != nil {
|
||||||
if bdatas, err = this.modelBuried.getUserBurieds(uid); err != nil {
|
return
|
||||||
|
}
|
||||||
|
if bdatas, err = model.getUserBurieds(uid); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range condiIds {
|
for _, v := range condiIds {
|
||||||
@ -110,7 +113,7 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if chanage {
|
if chanage {
|
||||||
err = this.modelBuried.updateUserBurieds(uid, bdatas)
|
err = model.updateUserBurieds(uid, bdatas)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user