取关
作者:互联网
和关注反着来就行
根据writerId和粉丝id查询用户
执行删除操作
redis粉丝数 - 1
public void deleteFans(String writerId, String fanId) {
QueryWrapper<Fans> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("writer_id", writerId);
queryWrapper.eq("fan_id", fanId);
fanMapper.delete(queryWrapper);
String redisWriterFollowCounts = redisOperator.get(REDIS_WRITER_FOLLOW_COUNTS + ":" + writerId);
String redisMyFollowCounts = redisOperator.get(REDIS_MY_FOLLOW_COUNTS + ":" + writerId);
if (Integer.parseInt(redisWriterFollowCounts) > 0) {
redisOperator.decrement(REDIS_WRITER_FOLLOW_COUNTS + ":" + writerId, 1);
}
if (Integer.parseInt(redisMyFollowCounts) > 0) {
redisOperator.decrement(REDIS_MY_FOLLOW_COUNTS + ":" + fanId, 1);
}
}
标签:redisOperator,String,writerId,REDIS,取关,FOLLOW,COUNTS 来源: https://www.cnblogs.com/lyraHeartstrings/p/15320990.html