source: src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java@ 40935d3

Last change on this file since 40935d3 was 90317ea, checked in by DenicaKj <dkorvezir@…>, 22 months ago

Events and Event

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package com.example.moviezone.service.Impl;
2
3import com.example.moviezone.model.Film;
4import com.example.moviezone.model.procedures.FilmsReturnTable;
5import com.example.moviezone.repository.FilmRepository;
6import com.example.moviezone.service.FilmService;
7import org.springframework.stereotype.Service;
8
9import java.time.LocalDate;
10import java.util.Collections;
11import java.util.List;
12import java.util.Optional;
13
14@Service
15public class FilmServiceImpl implements FilmService {
16 private final FilmRepository filmRepository;
17
18 public FilmServiceImpl(FilmRepository filmRepository) {
19 this.filmRepository = filmRepository;
20 }
21
22 @Override
23 public List<Film> findAllFilms() {
24 return filmRepository.findAll();
25 }
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 }
31
32 @Override
33 public Optional<Film> getFilmById(Long id) {
34 return filmRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();
35 }
36
37 @Override
38 public List<Film> getFilmsFromCinema(int id) {
39 return filmRepository.getFilmsFromCinema(id);
40 }
41
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
52}
Note: See TracBrowser for help on using the repository browser.