package rank import ( "dcg/app/user_center/usercenter" pbRank "dcg/game/pb/rank" "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 *pbRank.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([]*pbRank.RankPvpResp_Item, 0, len(result.Items)) for _, item := range result.Items { items = append(items, &pbRank.RankPvpResp_Item{ Uid: item.Uid, Uname: item.Uname, Score: item.Score, Avatar: item.Avatar, }) } return s.Response(&pbRank.RankPvpResp{ Type: result.Type, Items: items, }) }