粉丝数和关注数显示
从redis中查询数据 若为空则显示0 刚注册的用户肯定没有粉丝和关注的直接显示0即可
这个在userInfo中添加即可
// 获取粉丝数和关注数 将粉丝数和关注数设置到用户基本信息中 查询用户时从redis中获取粉丝数和关注数即可
Integer redisWriterFollowCounts = getCountFromRedis(REDIS_WRITER_FOLLOW_COUNTS + ":" + userId);
Integer redisMyFollowCounts = getCountFromRedis(REDIS_MY_FOLLOW_COUNTS + ":" + userId);
accountBasicInfoVO.setMyFansCounts(redisMyFollowCounts);
accountBasicInfoVO.setMyFollowCounts(redisWriterFollowCounts);
protected Integer getCountFromRedis(String key) {
String count = redisOperator.get(key);
if (StringUtils.isBlank(count)) {
count = "0";
}
return Integer.parseInt(count);
}
虽然道路是曲折的,但前途是光明的。