Changeset e0ef1b1 in Git for src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java
- Timestamp:
- 02/04/22 23:22:13 (3 years ago)
- Branches:
- main
- Children:
- 5b447b0
- Parents:
- 3ded84d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java
r3ded84d re0ef1b1 1 1 package com.wediscussmovies.project.service.impl; 2 2 3 import com.wediscussmovies.project.model.*; 3 import com.wediscussmovies.project.model.exception.GenreNotExistException; 4 import com.wediscussmovies.project.querymodels.GenreLikes; 4 5 import com.wediscussmovies.project.repository.GenreRepository; 6 import com.wediscussmovies.project.model.Genre; 5 7 import com.wediscussmovies.project.service.GenreService; 6 8 import org.springframework.stereotype.Service; 7 9 8 10 import java.util.List; 9 import java.util.Optional;10 11 11 12 @Service … … 18 19 19 20 @Override 20 public Optional<Genre>findById(Integer id) {21 return genreRepository.findById(id);21 public Genre findById(Integer id) { 22 return this.genreRepository.findById(id).orElseThrow(() -> new GenreNotExistException(id)); 22 23 } 23 24 24 25 @Override 25 26 public List<Genre> findAllByType(String genre) { 26 return genreRepository.findAllByGenreType(genre);27 return this.genreRepository.findAllByGenreType(genre); 27 28 } 28 29 … … 30 31 public Genre save(String genreName) { 31 32 Genre genre = new Genre(genreName); 32 return genreRepository.save(genre); 33 return this.genreRepository.save(genre); 34 } 35 36 @Override 37 public List<GenreLikes> findAllWithLikes() { 38 return this.genreRepository.findAllWithLikes(); 33 39 } 34 40 35 41 @Override 36 42 public List<Genre> findAll() { 37 return genreRepository.findAll();43 return this.genreRepository.findAll(); 38 44 } 39 45 }
Note:
See TracChangeset
for help on using the changeset viewer.