source: source/MovieZilla-master/src/main/java/com/example/demo/service/ServiceImpl/MovieServiceImpl.java

Last change on this file was fc7ec52, checked in by darkopopovski <darkopopovski39@…>, 2 years ago

all files

  • Property mode set to 100644
File size: 2.3 KB
Line 
1package com.example.demo.service.ServiceImpl;
2
3import com.example.demo.model.Movie;
4import com.example.demo.model.dto.MovieDto;
5import com.example.demo.repository.MovieRepository;
6import com.example.demo.service.MovieService;
7import org.springframework.stereotype.Service;
8import org.springframework.transaction.annotation.Transactional;
9
10import java.util.List;
11import java.util.Optional;
12
13@Service
14public class MovieServiceImpl implements MovieService {
15 private final MovieRepository movieRepository;
16
17 public MovieServiceImpl(MovieRepository movieRepository) {
18 this.movieRepository = movieRepository;
19 }
20
21 @Override
22 public List<Movie> findAll() {
23 return this.movieRepository.findAll();
24 }
25
26 @Override
27 public List<Movie> listMovies() {
28 return this.movieRepository.findAll();
29 }
30
31 @Override
32 public Optional<Movie> findAllByID(Integer id) {
33 return this.movieRepository.findAllByID(id);
34 }
35
36 @Override
37 public Optional<Movie> findById(Integer id) {
38 return this.movieRepository.findById(id);
39 }
40
41 @Override
42 public void deleteById(Integer movie_id){
43 this.movieRepository.deleteById(movie_id);
44 }
45
46 @Override
47 public Optional<Movie> save(Integer movie_id, String movie_name,String movie_age_category,String movie_cast,String movie_production,String film_director,String movie_time_duration) {
48 return Optional.of(this.movieRepository.save(new Movie(movie_id, movie_name, movie_age_category, movie_cast, movie_production,film_director, movie_time_duration)));
49 }
50
51
52 @Override
53 public Optional<Movie> save(MovieDto movieDto) {
54 this.movieRepository.deleteById(movieDto.getMovie_id());
55 return Optional.of(this.movieRepository.save(new Movie(movieDto.getMovie_id(),movieDto.getMovie_name(), movieDto.getMovie_cast(), movieDto.getMovie_age_category(), movieDto.getMovie_production(),movieDto.getMovie_film_director(), movieDto.getMovie_time_duration())));
56 }
57
58 @Override
59 public Optional<Movie> findByName(String movie_name) {
60 return this.movieRepository.findByName(movie_name);
61 }
62
63 @Override
64 public void deleteByName(String movie_name) {
65 this.movieRepository.deleteMovieByName(movie_name);
66 }
67
68 @Override
69 public Optional<Movie> findAllByName(String s) {
70 return this.movieRepository.findAllByName(s);
71 }
72
73
74}
Note: See TracBrowser for help on using the repository browser.