Пример #1
0
  @Transactional
  public Collection<Rating> saveRatings(String userLogin, String id, List<Rating> rating) {

    LOG.info(
        "user {} has rated movie {} as {} commented {}",
        userLogin,
        id,
        rating.get(0).getStars(),
        rating.get(0).getComment());

    Movie movie = movieRepository.findById(id);
    User u = userRepository.findByLogin(userLogin);
    u.rate(template, movie, rating.get(0).getStars(), rating.get(0).getComment());

    return rating;
  }
Пример #2
0
 @Transactional
 public List<Review> saveReviews(String userLogin, String id, List<Review> reviews) {
   Movie movie = movieRepository.findById(id);
   User user = userRepository.findByLogin(userLogin);
   Review review = template.save(reviews.get(0));
   user.addReview(review);
   review.reviewed(movie);
   template.save(review);
   template.save(user);
   ;
   return new ArrayList<Review>() {
     {
       add(review);
     }
   };
 }