You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
package rank
|
|
|
|
import (
|
|
"dcg/app/user_center/usercenter"
|
|
pbGameZhg "dcg/game/pb/game/zhg"
|
|
"dcg/game/svc"
|
|
"git.noahlan.cn/northlan/ngs/component"
|
|
"git.noahlan.cn/northlan/ngs/session"
|
|
)
|
|
|
|
type Rank struct {
|
|
component.Base
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewRank(svcCtx *svc.ServiceContext) *Rank {
|
|
return &Rank{
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (p *Rank) Init() {
|
|
}
|
|
|
|
func (p *Rank) Shutdown() {
|
|
}
|
|
|
|
func (p *Rank) CMD() string {
|
|
return "rank"
|
|
}
|
|
|
|
func (p *Rank) Prefix() string {
|
|
return ""
|
|
}
|
|
|
|
// Pvp pvp排行榜获取
|
|
func (p *Rank) Pvp(s *session.Session, msg *pbGameZhg.RankPvpReq) error {
|
|
result, err := p.svcCtx.UserCenterRpc.RankPvp(p.svcCtx.Ctx, &usercenter.RankPvpReq{
|
|
Type: msg.Type,
|
|
TopN: msg.TopN,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
items := make([]*pbGameZhg.RankPvpResp_Item, 0, len(result.Items))
|
|
for _, item := range result.Items {
|
|
items = append(items, &pbGameZhg.RankPvpResp_Item{
|
|
Uid: item.Uid,
|
|
Uname: item.Uname,
|
|
Score: item.Score,
|
|
Avatar: item.Avatar,
|
|
})
|
|
}
|
|
return s.Response(&pbGameZhg.RankPvpResp{
|
|
Type: result.Type,
|
|
Items: items,
|
|
})
|
|
}
|