将关注过的用户id存如数据库中
//关注或者取关@Overridepublic Result follow(Long id, Boolean flag) {//1.获取当前登录用户的idUserDTO user = UserHolder.getUser();if(user==null){return Result.fail("请先登录");}Long userId = user.getId();//2.判断是关注还是取关if(flag){//3.关注 添加到数据库Follow follow = new Follow();follow.setUserId(userId);follow.setFollowUserId(id);this.save(follow);}else {//4.取关 删除LambdaQueryWrapper<Follow> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.eq(Follow::getUserId,userId).eq(Follow::getFollowUserId,id);remove(queryWrapper);}return Result.ok();}//判断是否关注@Overridepublic Result isFollow(Long id) {//1.获取当前登录用户的idUserDTO user = UserHolder.getUser();if(user==null){return Result.fail("请先登录");}Long userId = user.getId();//2.查询数据库中是否有数据LambdaQueryWrapper<Follow> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.eq(Follow::getUserId,userId).eq(Follow::getFollowUserId,id);int count = this.count(queryWrapper);if(count>0){return Result.ok("关注了");}return Result.ok("未关注");}