排行榜20位优化

back_recharge
mengchengzhen 2021-02-24 10:27:08 +08:00
parent 91dd46a809
commit d8160bdfb0
3 changed files with 6 additions and 5 deletions

View File

@ -16,6 +16,7 @@ public class RankHandler extends BaseHandler<PlayerInfoProto.RankRequest> {
@Override
public void processWithProto(ISession iSession, PlayerInfoProto.RankRequest proto) throws Exception {
RankLogic.getInstance().getRank(iSession,proto.getType(),proto.getActiviteId(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
RankLogic.getInstance().getRank(iSession,proto.getType(),proto.getActiviteId(),
proto.getIndex(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
}
}

View File

@ -47,7 +47,7 @@ public class RankLogic {
public static class Instance {
public final static RankLogic instance = new RankLogic();
}
public void getRank(ISession session, int type, int activityId,MessageTypeProto.MessageType messageType) throws Exception {
public void getRank(ISession session, int type, int activityId,int index,MessageTypeProto.MessageType messageType) throws Exception {
LOGGER.info("获取排行榜信息type={},activityId={}",type,activityId);
int page = 1;
String rkey = "";
@ -73,7 +73,7 @@ public class RankLogic {
}
}else{
rankResponse = rank.getRank(session.getUid(),rkey,1, -1);
rankResponse = rank.getRank(session.getUid(),rkey,index/20+1, 20);
}
ReportUtil.onReportEvent(UserManager.getUser(session.getUid()), ReportEventEnum.CHECK_RANKING.getType(),String.valueOf(type));
MessageUtil.sendMessage(session,1,messageType.getNumber(),rankResponse,true);

View File

@ -47,8 +47,8 @@ public abstract class AbstractRank implements IRank {
}
int start = (page - 1) * rankEndLine, end = page * rankEndLine - 1;
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = getRankByKey(rkey,start,end);
if(start==0){
start=1;
if(start%rankEndLine == 0){
start++;
}
PlayerInfoProto.RankResponse.Builder allUserResponse = getAllUserResponse(zsetreverseRangeWithScores,start);
//当前用户信息