热榜点赞

duhui 2022-12-12 14:16:45 +08:00
parent 5861711eaa
commit ce9d4f5b27
1 changed files with 4 additions and 2 deletions

View File

@ -41,7 +41,6 @@ public class LikeHeroRankHandler extends BaseHandler<HeroInfoProto.LikeHeroRankR
String userId = String.valueOf(user.getId()); String userId = String.valueOf(user.getId());
// 英雄是否点赞过验证 // 英雄是否点赞过验证
HashSet<Integer> entry = RedisUtil.getInstence().getMapEntry(RedisKey.USER_LIKE_HERO_HOT_RANK, rankSubId, userId, HashSet.class); HashSet<Integer> entry = RedisUtil.getInstence().getMapEntry(RedisKey.USER_LIKE_HERO_HOT_RANK, rankSubId, userId, HashSet.class);
if (entry != null && entry.contains(heroTid)){ if (entry != null && entry.contains(heroTid)){
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"该英雄已点赞"); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"该英雄已点赞");
@ -49,7 +48,7 @@ public class LikeHeroRankHandler extends BaseHandler<HeroInfoProto.LikeHeroRankR
// 排行榜是否开启验证 // 排行榜是否开启验证
Map<Integer, SHotRanking> config = STableManager.getConfig(SHotRanking.class); Map<Integer, SHotRanking> config = STableManager.getConfig(SHotRanking.class);
SHotRanking hotRanking = config.get(rankSubId); SHotRanking hotRanking = config.get(Integer.parseInt(rankSubId));
if (hotRanking == null || hotRanking.getOpen() == 0){ if (hotRanking == null || hotRanking.getOpen() == 0){
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"排行榜未开启:"+rankSubId); throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"排行榜未开启:"+rankSubId);
} }
@ -59,6 +58,9 @@ public class LikeHeroRankHandler extends BaseHandler<HeroInfoProto.LikeHeroRankR
rank.addRank(proto.getHeroTid(), rankSubId, 1); rank.addRank(proto.getHeroTid(), rankSubId, 1);
// 更新点赞记录 // 更新点赞记录
if (entry == null){
entry = new HashSet<>();
}
entry.add(heroTid); entry.add(heroTid);
RedisUtil.getInstence().putMapEntry(RedisKey.USER_LIKE_HERO_HOT_RANK, rankSubId, userId, entry); RedisUtil.getInstence().putMapEntry(RedisKey.USER_LIKE_HERO_HOT_RANK, rankSubId, userId, entry);