Changeset ad4243e in Git for src/main/java/com/wediscussmovies/project/service/impl
- Timestamp:
- 02/07/22 21:26:03 (3 years ago)
- Branches:
- main
- Children:
- 0226942
- Parents:
- 7f36551 (diff), 3c0f9a9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Mato-77 <56981531+Mato-77@…> (02/07/22 21:26:03)
- git-committer:
- GitHub <noreply@…> (02/07/22 21:26:03)
- Location:
- src/main/java/com/wediscussmovies/project/service/impl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java
r7f36551 rad4243e 1 1 package com.wediscussmovies.project.service.impl; 2 2 3 import com.wediscussmovies.project.model.User; 3 4 import com.wediscussmovies.project.model.exception.GenreNotExistException; 5 import com.wediscussmovies.project.model.exception.UserNotExistException; 6 import com.wediscussmovies.project.model.primarykeys.GenreLikesPK; 7 import com.wediscussmovies.project.model.primarykeys.UserGenresPK; 8 import com.wediscussmovies.project.model.relation.MovieLikes; 9 import com.wediscussmovies.project.model.relation.UserGenres; 4 10 import com.wediscussmovies.project.querymodels.GenreLikes; 11 import com.wediscussmovies.project.repository.GenreLikesRepository; 5 12 import com.wediscussmovies.project.repository.GenreRepository; 6 13 import com.wediscussmovies.project.model.Genre; 14 import com.wediscussmovies.project.repository.UserRepository; 7 15 import com.wediscussmovies.project.service.GenreService; 8 16 import org.springframework.stereotype.Service; … … 13 21 public class GenreServiceImpl implements GenreService { 14 22 private final GenreRepository genreRepository; 23 private final UserRepository userRepository; 24 private final GenreLikesRepository genreLikesRepository; 15 25 16 public GenreServiceImpl(GenreRepository genreRepository) { 26 27 public GenreServiceImpl(GenreRepository genreRepository, UserRepository userRepository, GenreLikesRepository genreLikesRepository) { 17 28 this.genreRepository = genreRepository; 29 this.userRepository = userRepository; 30 this.genreLikesRepository = genreLikesRepository; 18 31 } 19 32 … … 36 49 @Override 37 50 public List<GenreLikes> findAllWithLikes() { 38 return this.genreRepository.findAllWithLikes(); 51 List<GenreLikes> genreLikesList = this.genreRepository.findAllWithLikes(); 52 genreLikesList.sort(GenreLikes.sorter); 53 return genreLikesList; 39 54 } 40 55 … … 43 58 return this.genreRepository.findAll(); 44 59 } 60 61 @Override 62 public void likeGenre(Integer genreId, Integer userId) { 63 User user = this.userRepository.findById(userId).orElseThrow(() -> new UserNotExistException(userId.toString())); 64 Genre genre = this.genreRepository.findById(genreId).orElseThrow(() -> new GenreNotExistException(genreId)); 65 this.genreLikesRepository.save(new UserGenres(genre, user)); 66 } 67 68 @Override 69 public void unlikeGenre(Integer genreId, Integer userId) { 70 UserGenresPK movieLikesPK = new UserGenresPK(userId, genreId); 71 this.genreLikesRepository.deleteById(movieLikesPK); 72 } 45 73 } -
src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java
r7f36551 rad4243e 76 76 77 77 @Override 78 public List<Integer> listAllIds() { 79 return this.movieRepository.findAllMovieIds(); 80 } 81 82 @Override 78 83 @Transactional 79 84 public Movie save(String title, String description, String imageUrl, -
src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java
r7f36551 rad4243e 9 9 import com.wediscussmovies.project.model.primarykeys.PersonRatesPK; 10 10 import com.wediscussmovies.project.model.relation.MovieActors; 11 import com.wediscussmovies.project.model.relation.MovieRates;12 11 import com.wediscussmovies.project.model.relation.PersonRates; 13 import com.wediscussmovies.project.repository.MovieActorsRepository; 14 import com.wediscussmovies.project.repository.MovieRepository; 15 import com.wediscussmovies.project.repository.PersonRatesRepository; 16 import com.wediscussmovies.project.repository.PersonRepository; 12 import com.wediscussmovies.project.repository.*; 17 13 import com.wediscussmovies.project.model.Person; 18 14 import com.wediscussmovies.project.service.PersonService; … … 32 28 private final MovieActorsRepository movieActorsRepository; 33 29 private final PersonRatesRepository personRatesRepository; 34 35 30 36 31 public PersonServiceImpl(PersonRepository personRepository, … … 156 151 157 152 153 154 158 155 private void addActorForMovies(Person person, List<Integer> movieIds){ 159 156
Note:
See TracChangeset
for help on using the changeset viewer.