扩展数据初始调整

This commit is contained in:
meixiongfeng 2023-03-08 15:10:56 +08:00
parent eb9f2bb1ec
commit 7b79fd7d78
2 changed files with 19 additions and 17 deletions

View File

@ -81,22 +81,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
return
}
//初始化用户扩展
initUpdate := map[string]interface{}{
"modifynameCount": 1, //修改名称1次
"sociatyTicket": globalConf.GuildBossInitialNum, //公会BOSS挑战券
"expitem": make(map[string]int32, 0), // 初始化
"mline": make(map[string]int32, 0),
}
if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), initUpdate); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("创建初始修改名称次数",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: initUpdate},
log.Field{Key: "err", Value: err.Error()},
)
return
}
var (
res []*cfg.Gameatn
)

View File

@ -43,7 +43,25 @@ func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err
}
}
} else {
if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments != err {
if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments == err {
globalConf := this.module.configure.GetGlobalConf()
initUpdate := map[string]interface{}{
"uid": uid,
"modifynameCount": 1, //修改名称1次
"sociatyTicket": globalConf.GuildBossInitialNum, //公会BOSS挑战券
"expitem": make(map[string]int32, 0), // 初始化
"mline": make(map[string]int32, 0),
}
result.SociatyTicket = globalConf.GuildBossInitialNum
if err = this.module.modelExpand.ChangeUserExpand(uid, initUpdate); err != nil {
this.module.Error("创建初始修改名称次数",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: initUpdate},
log.Field{Key: "err", Value: err.Error()},
)
return
}
this.module.Error("Get", log.Field{Key: "uid", Value: uid})
return result, err
}