}
User target = userRepository.findOne(targetId);
if(target==null){
throw new RuntimeException("Invalid user id : " + targetId);
}
FollowShip fs = followShipRepository.getByTargetAndFollowed(targetId, signInUser.getId());
boolean followed = false;
if(fs!=null && fs.getStatus() == ApplicationConstants.FOLLOWSHIP_DISABLED){
followed = true;
fs.setStatus(ApplicationConstants.FOLLOWSHIP_NORMAL);
fs.setUpdatedAt(new Date());
userRepository.inc(signInUser.getId(), "followCount", 1);
userRepository.inc(target.getId(), "fansCount", 1);
}else if(fs==null){
followed = true;
fs = new FollowShip();
fs.setCreatedAt(new Date());
fs.setUpdatedAt(fs.getCreatedAt());
fs.setTarget(target);
fs.setFollowed(signInUser);
fs.setStatus(ApplicationConstants.FOLLOWSHIP_NORMAL);
userRepository.inc(signInUser.getId(), "followCount", 1);
userRepository.inc(target.getId(), "fansCount", 1);
}
if(followed){
followShipRepository.save(fs);