@Override public List<User> following(String username) { Assert.hasText(username); // make sure id's are valid User follower = userRepository.findByUsername(username); return followerRepository.findFollowing(follower.getId()); }
@Override public void unfollow(String followerUsername, String username) { Assert.hasText(followerUsername); Assert.hasText(username); // make sure id's are valid User followerUser = userRepository.findByUsername(followerUsername); User followedUser = userRepository.findByUsername(username); Follower findFollower = followerRepository.findFollower(followedUser.getId(), followerUser.getId()); followerRepository.delete(findFollower); }
@Override public void follow(String followerUsername, String username) { Assert.hasText(followerUsername); Assert.hasText(username); // make sure id's are valid User followerUser = userRepository.findByUsername(followerUsername); User followedUser = userRepository.findByUsername(username); Follower follower = new Follower(); follower.setFollowerId(followerUser.getId()); follower.setUserId(followedUser.getId()); followerRepository.save(follower); }