更新玩家基础信息
This commit is contained in:
parent
db953e2029
commit
7b444d0be3
@ -33,6 +33,11 @@ type (
|
||||
IPayDelivery interface {
|
||||
Delivery(session IUserSession, pId int32) (errdata *pb.ErrorData, items []*pb.UserAtno)
|
||||
}
|
||||
|
||||
// 修改玩家基本数据
|
||||
IUpdateUserBaseInfo interface {
|
||||
UpdateUserBaseInfo(session IUserSession, info *pb.BaseUserInfo) (err error)
|
||||
}
|
||||
)
|
||||
|
||||
/*
|
||||
@ -274,6 +279,7 @@ type (
|
||||
QiecuoFinishNotify(redUid, matchId string) error
|
||||
// 红点
|
||||
IGetReddot
|
||||
IUpdateUserBaseInfo
|
||||
}
|
||||
|
||||
//聊天系统
|
||||
|
@ -48,9 +48,9 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA
|
||||
}
|
||||
}
|
||||
leftCount = int32(comm.AssistHeroCount - len(list.Data))
|
||||
localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{})
|
||||
randomIndex := comm.GetRandNum(0, int32(localNum))
|
||||
cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(randomIndex)).SetLimit(int64(leftCount))) //.skip(1).limit(1)
|
||||
// localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{})
|
||||
// randomIndex := comm.GetRandNum(0, int32(localNum))
|
||||
cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1)
|
||||
for cur.Next(context.TODO()) {
|
||||
tmp := &pb.DBFriend{}
|
||||
if err = cur.Decode(tmp); err == nil {
|
||||
@ -75,6 +75,23 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA
|
||||
return
|
||||
}
|
||||
|
||||
if len(list.Data) == 0 { // 异常处理
|
||||
leftCount = int32(comm.AssistHeroCount - len(list.Data))
|
||||
// localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{})
|
||||
// randomIndex := comm.GetRandNum(0, int32(localNum))
|
||||
cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1)
|
||||
for cur.Next(context.TODO()) {
|
||||
tmp := &pb.DBFriend{}
|
||||
if err = cur.Decode(tmp); err == nil {
|
||||
list.Data[tmp.Uid] = tmp.Info.Name
|
||||
heros = append(heros, tmp.Hero)
|
||||
}
|
||||
}
|
||||
|
||||
err = this.module.modelAssist.modifyAssistData(session.GetUserId(), map[string]interface{}{
|
||||
"data": list.Data,
|
||||
})
|
||||
} else {
|
||||
for k := range list.Data {
|
||||
uids = append(uids, k)
|
||||
}
|
||||
@ -90,6 +107,8 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA
|
||||
for _, v := range friends {
|
||||
heros = append(heros, v.Hero)
|
||||
}
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "getassisthero", &pb.FriendGetAssistHeroResp{
|
||||
Data: list,
|
||||
Hero: heros,
|
||||
|
@ -6,10 +6,12 @@ package friend
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -252,3 +254,31 @@ func (this *Friend) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Friend) UpdateUserBaseInfo(session comm.IUserSession, info *pb.BaseUserInfo) (err error) {
|
||||
|
||||
if db.IsCross() {
|
||||
err = this.modelFriend.Change(session.GetUserId(), map[string]interface{}{
|
||||
"info": info,
|
||||
})
|
||||
} else {
|
||||
var (
|
||||
model *db.DBModel
|
||||
conn_ *db.DBConn
|
||||
)
|
||||
// 跨服
|
||||
conn_, err = db.Cross() // 获取跨服数据库对象
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if model = db.NewDBModelByExpired(comm.TableFriend, conn_); model == nil {
|
||||
err = fmt.Errorf("cand found table :%s,%v", comm.TableFriend, conn_)
|
||||
return
|
||||
}
|
||||
err = model.Change(session.GetUserId(), map[string]interface{}{
|
||||
"info": info,
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
@ -92,6 +93,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
||||
update["avatar"] = globalConf.GirlHeadPortrait
|
||||
}
|
||||
user.Gender = req.Gender
|
||||
user.Name = req.NickName
|
||||
user.CurSkin = req.Skin
|
||||
user.Gender = req.Gender
|
||||
session.SetMate(comm.Session_User, user)
|
||||
if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -124,7 +128,27 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
||||
|
||||
//异步逻辑
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
baseInfo := &pb.BaseUserInfo{
|
||||
Uid: user.Uid,
|
||||
Sid: user.Sid,
|
||||
Name: user.Name,
|
||||
Gender: user.Gender,
|
||||
Skin: user.CurSkin,
|
||||
Aframe: user.Curaframe,
|
||||
Title: user.Curtitle,
|
||||
Lv: user.Lv,
|
||||
}
|
||||
for _, m := range this.module.notifyUserinfo {
|
||||
|
||||
i, err := this.service.GetModule(core.M_Modules(m))
|
||||
if err != nil {
|
||||
this.module.Errorln(err)
|
||||
continue
|
||||
}
|
||||
if ic, ok := i.(comm.IUpdateUserBaseInfo); ok {
|
||||
ic.UpdateUserBaseInfo(session, baseInfo)
|
||||
}
|
||||
}
|
||||
this.mail.SendMailByCid(session, comm.Welcomemail, nil)
|
||||
if len(tasks) > 0 {
|
||||
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
||||
|
@ -65,6 +65,7 @@ type User struct {
|
||||
timerLock sync.Mutex
|
||||
timerMap map[string]*time.Ticker
|
||||
reddot comm.IReddot
|
||||
notifyUserinfo []string // userinfo change
|
||||
}
|
||||
|
||||
func (this *User) GetType() core.M_Modules {
|
||||
@ -107,6 +108,7 @@ func (this *User) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.reddot = module.(comm.IReddot)
|
||||
this.notifyUserinfo = append(this.notifyUserinfo, string(comm.ModuleFriend)) // 只要涉及到更新userinof 信息的模块在此注册
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user