main
Last change
on this file since e0ef1b1 was e0ef1b1, checked in by Test <matonikolov77@…>, 2 years ago |
Added CRUD for movies,persons,discussion,replies,genres
Added ajaxcalls
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | package com.wediscussmovies.project.service.impl;
|
---|
2 |
|
---|
3 | import com.wediscussmovies.project.model.exception.GenreNotExistException;
|
---|
4 | import com.wediscussmovies.project.querymodels.GenreLikes;
|
---|
5 | import com.wediscussmovies.project.repository.GenreRepository;
|
---|
6 | import com.wediscussmovies.project.model.Genre;
|
---|
7 | import com.wediscussmovies.project.service.GenreService;
|
---|
8 | import org.springframework.stereotype.Service;
|
---|
9 |
|
---|
10 | import java.util.List;
|
---|
11 |
|
---|
12 | @Service
|
---|
13 | public class GenreServiceImpl implements GenreService {
|
---|
14 | private final GenreRepository genreRepository;
|
---|
15 |
|
---|
16 | public GenreServiceImpl(GenreRepository genreRepository) {
|
---|
17 | this.genreRepository = genreRepository;
|
---|
18 | }
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public Genre findById(Integer id) {
|
---|
22 | return this.genreRepository.findById(id).orElseThrow(() -> new GenreNotExistException(id));
|
---|
23 | }
|
---|
24 |
|
---|
25 | @Override
|
---|
26 | public List<Genre> findAllByType(String genre) {
|
---|
27 | return this.genreRepository.findAllByGenreType(genre);
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public Genre save(String genreName) {
|
---|
32 | Genre genre = new Genre(genreName);
|
---|
33 | return this.genreRepository.save(genre);
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public List<GenreLikes> findAllWithLikes() {
|
---|
38 | return this.genreRepository.findAllWithLikes();
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public List<Genre> findAll() {
|
---|
43 | return this.genreRepository.findAll();
|
---|
44 | }
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.