Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
983750153e
@ -160,5 +160,11 @@
|
||||
"open": true,
|
||||
"routrules": "~/worker",
|
||||
"describe": "好友助战英雄列表"
|
||||
},
|
||||
{
|
||||
"msgid": "gourmet.getranduser",
|
||||
"open": true,
|
||||
"routrules": "~/worker",
|
||||
"describe": "获取在线玩家数据"
|
||||
}
|
||||
]
|
@ -5,7 +5,9 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
"go_dreamfactory/utils"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
@ -32,8 +34,9 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.GourmetGetRa
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
// 获取在线玩家信息
|
||||
onlineList, err := this.module.ModuleUser.CrossUserOnlineList()
|
||||
onlineList, err := this.module.ModuleUser.UserOnlineList()
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
@ -61,15 +64,21 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.GourmetGetRa
|
||||
}
|
||||
left := int(req.People) - len(mapUser)
|
||||
if left > 0 { // 一个人也没有 那就从db 中随机取
|
||||
if _data, err1 := this.module.modelGourmet.DB.Find(core.SqlTable(comm.TableUser), bson.M{}, options.Find().SetSort(bson.M{"lv": -1}).SetLimit(int64(req.People))); err1 == nil {
|
||||
for _data.Next(context.TODO()) {
|
||||
temp := &pb.DBUser{}
|
||||
if err = _data.Decode(temp); err == nil {
|
||||
if len(mapUser) >= int(req.People) {
|
||||
break
|
||||
}
|
||||
if _, ok := mapUser[temp.Uid]; !ok {
|
||||
szDbUser = append(szDbUser, temp)
|
||||
tag, _, b := utils.UIdSplit(session.GetUserId())
|
||||
if b {
|
||||
if conn, err := db.ServerDBConn(tag); err == nil {
|
||||
dbModel := db.NewDBModel(comm.TableHero, time.Hour, conn)
|
||||
if _data, err1 := dbModel.DB.Find(core.SqlTable(comm.TableUser), bson.M{}, options.Find().SetSort(bson.M{"lv": -1}).SetLimit(int64(req.People))); err1 == nil {
|
||||
for _data.Next(context.TODO()) {
|
||||
temp := &pb.DBUser{}
|
||||
if err = _data.Decode(temp); err == nil {
|
||||
if len(mapUser) >= int(req.People) {
|
||||
break
|
||||
}
|
||||
if _, ok := mapUser[temp.Uid]; !ok {
|
||||
szDbUser = append(szDbUser, temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,9 @@ func (this *User) GetUserSession(uid string) *pb.CacheUser {
|
||||
|
||||
// 清除session
|
||||
func (this *User) CleanSession(session comm.IUserSession) {
|
||||
this.modelUser.updateOfflineTime(session.GetUserId())
|
||||
if !this.IsCross() {
|
||||
this.modelUser.updateOfflineTime(session.GetUserId())
|
||||
}
|
||||
sId := fmt.Sprintf("%s-%s", comm.RDS_SESSION, session.GetUserId())
|
||||
this.modelSession.Del(sId, db.SetDBMgoLog(false))
|
||||
this.modelSession.DelListlds(comm.RDS_SESSION, session.GetUserId())
|
||||
|
Loading…
Reference in New Issue
Block a user