[11dea8f] | 1 | package com.example.moviezone.service.Impl;
|
---|
| 2 |
|
---|
| 3 | import com.example.moviezone.model.Film;
|
---|
[8d49568] | 4 | import com.example.moviezone.model.procedures.FilmsReturnTable;
|
---|
[1b248e4] | 5 | import com.example.moviezone.repository.FilmRepository;
|
---|
[11dea8f] | 6 | import com.example.moviezone.service.FilmService;
|
---|
| 7 | import org.springframework.stereotype.Service;
|
---|
| 8 |
|
---|
[302b233] | 9 | import java.time.LocalDate;
|
---|
[eb5426c] | 10 | import java.util.Collections;
|
---|
[11dea8f] | 11 | import java.util.List;
|
---|
[eb5426c] | 12 | import java.util.Optional;
|
---|
[11dea8f] | 13 |
|
---|
| 14 | @Service
|
---|
| 15 | public class FilmServiceImpl implements FilmService {
|
---|
[1b248e4] | 16 | private final FilmRepository filmRepository;
|
---|
| 17 |
|
---|
| 18 | public FilmServiceImpl(FilmRepository filmRepository) {
|
---|
| 19 | this.filmRepository = filmRepository;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
[11dea8f] | 22 | @Override
|
---|
| 23 | public List<Film> findAllFilms() {
|
---|
[1b248e4] | 24 | return filmRepository.findAll();
|
---|
[11dea8f] | 25 | }
|
---|
[302b233] | 26 |
|
---|
| 27 | @Override
|
---|
| 28 | public Film save(String name, Integer duration, String actors, String genre, String age_category, String url, String director, LocalDate start_date, LocalDate end_date) {
|
---|
| 29 | return filmRepository.save(new Film(name,duration,actors,genre,age_category,url,director,start_date,end_date));
|
---|
| 30 | }
|
---|
[eb5426c] | 31 |
|
---|
| 32 | @Override
|
---|
| 33 | public Optional<Film> getFilmById(Long id) {
|
---|
| 34 | return filmRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();
|
---|
| 35 | }
|
---|
| 36 |
|
---|
[8d49568] | 37 | @Override
|
---|
[61fed7c] | 38 | public List<Film> getFilmsFromCinema(int id) {
|
---|
[8d49568] | 39 | return filmRepository.getFilmsFromCinema(id);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
[90317ea] | 42 | @Override
|
---|
| 43 | public List<Film> getFilmsFromCinemaNow(int id) {
|
---|
| 44 | return filmRepository.getFilmsFromCinemaNow(id);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | @Override
|
---|
| 48 | public List<Film> getFilmsNow() {
|
---|
| 49 | return filmRepository.getFilmsNow();
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[11dea8f] | 52 | }
|
---|