コード例 #1
0
  @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);
  }
コード例 #2
0
  @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());
  }
コード例 #3
0
  @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);
  }