Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
0a11b01ffb
@ -168,9 +168,99 @@
|
|||||||
"describe": "获取在线玩家数据"
|
"describe": "获取在线玩家数据"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"msgid": "arena",
|
"msgid": "sociaty.list",
|
||||||
"open": true,
|
"open": true,
|
||||||
"routrules": "~/worker",
|
"routrules": "~/worker",
|
||||||
"describe": "竞技场系统"
|
"describe": "公会列表"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.create",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "创建公会"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.setting",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会设置"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.search",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会搜索"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.apply",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会申请"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.applylist",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会申请列表"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.agree",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会申请同意"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.refuse",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会申请拒绝"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.dismiss",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会解散"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.quit",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "离开公会"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.mine",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "我的公会"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.members",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会成员"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.assign",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "公会转让"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.discharge",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "踢出公会"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "sociaty.settingjob",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "设置职位"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"msgid": "smithy.getranduser",
|
||||||
|
"open": true,
|
||||||
|
"routrules": "~/worker",
|
||||||
|
"describe": "获取在线玩家数据"
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -72,7 +72,7 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.GourmetGetRa
|
|||||||
for _data.Next(context.TODO()) {
|
for _data.Next(context.TODO()) {
|
||||||
temp := &pb.DBUser{}
|
temp := &pb.DBUser{}
|
||||||
if err = _data.Decode(temp); err == nil {
|
if err = _data.Decode(temp); err == nil {
|
||||||
if len(mapUser) >= int(req.People) {
|
if len(mapUser)+len(szDbUser) >= int(req.People) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if _, ok := mapUser[temp.Uid]; !ok {
|
if _, ok := mapUser[temp.Uid]; !ok {
|
||||||
|
@ -5,7 +5,9 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
@ -27,13 +29,14 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.SmithyGetRan
|
|||||||
szDbUser []*pb.DBUser
|
szDbUser []*pb.DBUser
|
||||||
mapUser map[string]struct{}
|
mapUser map[string]struct{}
|
||||||
)
|
)
|
||||||
mapUser = make(map[string]struct{}, req.People)
|
mapUser = make(map[string]struct{}, 0)
|
||||||
code = this.GetRandUserCheck(session, req)
|
code = this.GetRandUserCheck(session, req)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取在线玩家信息
|
// 获取在线玩家信息
|
||||||
onlineList, err := this.module.ModuleUser.CrossUserOnlineList()
|
onlineList, err := this.module.ModuleUser.UserOnlineList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
@ -61,11 +64,15 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.SmithyGetRan
|
|||||||
}
|
}
|
||||||
left := int(req.People) - len(mapUser)
|
left := int(req.People) - len(mapUser)
|
||||||
if left > 0 { // 一个人也没有 那就从db 中随机取
|
if left > 0 { // 一个人也没有 那就从db 中随机取
|
||||||
if _data, err1 := this.module.modelSmithy.DB.Find(core.SqlTable(comm.TableUser), bson.M{}, options.Find().SetSort(bson.M{"lv": -1}).SetLimit(int64(req.People))); err1 == nil {
|
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()) {
|
for _data.Next(context.TODO()) {
|
||||||
temp := &pb.DBUser{}
|
temp := &pb.DBUser{}
|
||||||
if err = _data.Decode(temp); err == nil {
|
if err = _data.Decode(temp); err == nil {
|
||||||
if len(mapUser) >= int(req.People) {
|
if len(mapUser)+len(szDbUser) >= int(req.People) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if _, ok := mapUser[temp.Uid]; !ok {
|
if _, ok := mapUser[temp.Uid]; !ok {
|
||||||
@ -76,9 +83,14 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.SmithyGetRan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for k := range mapUser {
|
for k := range mapUser {
|
||||||
user, _ := this.module.ModuleUser.GetRmoteUser(k)
|
if user, err := this.module.ModuleUser.GetRmoteUser(k); err == nil && user.Uid != "" {
|
||||||
szDbUser = append(szDbUser, user) // 转成user对象
|
szDbUser = append(szDbUser, user) // 转成user对象
|
||||||
|
} else {
|
||||||
|
this.module.Errorf("%v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), SmithyGetRandUserResp, &pb.SmithyGetRandUserResp{User: szDbUser})
|
session.SendMsg(string(this.module.GetType()), SmithyGetRandUserResp, &pb.SmithyGetRandUserResp{User: szDbUser})
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user