89 lines
2.2 KiB
Go
89 lines
2.2 KiB
Go
package integral
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) RankListCheck(session comm.IUserSession, req *pb.IntegralRankListReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /排行榜获取
|
|
func (this *apiComp) RankList(session comm.IUserSession, req *pb.IntegralRankListReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
uids []string
|
|
ranks []*pb.DBIntegralBoss
|
|
ranksmap map[string]*pb.DBIntegralBoss
|
|
// franks []*pb.DBIntegralBoss
|
|
players []*pb.DBIntegralRank
|
|
err error
|
|
)
|
|
|
|
if errdata = this.RankListCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if uids, err = this.module.modelRank.queryIntegralRankUser(int(req.Nandu)); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if ranks, err = this.module.modelIntegral.queryPlayers(uids); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
ranksmap = make(map[string]*pb.DBIntegralBoss)
|
|
for _, v := range ranks {
|
|
ranksmap[v.Uid] = v
|
|
}
|
|
players = make([]*pb.DBIntegralRank, 0, len(uids))
|
|
for _, v := range uids {
|
|
if player, ok := ranksmap[v]; ok {
|
|
players = append(players, &pb.DBIntegralRank{
|
|
Id: player.Uid,
|
|
Uinfo: player.Uinfo,
|
|
Nandu: player.Nandu,
|
|
Score: player.Score[req.Nandu],
|
|
Line: player.Line[req.Nandu],
|
|
Buff: player.Carrybuff[req.Nandu].Buff,
|
|
})
|
|
}
|
|
|
|
}
|
|
// // 获取好友
|
|
// fids := this.module.ModuleFriend.GetFriendList(session.GetUserId())
|
|
// if franks, err = this.module.modelIntegral.queryPlayers(fids); err != nil {
|
|
// errdata = &pb.ErrorData{
|
|
// Code: pb.ErrorCode_DBError,
|
|
// Title: pb.ErrorCode_DBError.ToString(),
|
|
// Message: err.Error(),
|
|
// }
|
|
// return
|
|
// }
|
|
// friends = make([]*pb.DBIntegralRank, len(franks))
|
|
// for i, v := range franks {
|
|
// friends[i] = &pb.DBIntegralRank{
|
|
// Id: v.Uid,
|
|
// Uinfo: v.Uinfo,
|
|
// Nandu: v.Nandu,
|
|
// Score: v.Score[req.Nandu],
|
|
// Line: v.Line[req.Nandu],
|
|
// }
|
|
// }
|
|
session.SendMsg(string(this.module.GetType()), "ranklist", &pb.IntegralRankListResp{
|
|
Ranks: players,
|
|
})
|
|
return
|
|
}
|