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

Last change on this file since afa6544 was 8d49568, checked in by DenicaKj <dkorvezir@…>, 22 months ago

trying to call a function from database

  • Property mode set to 100644
File size: 1.3 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<FilmsReturnTable> getFilmsFromCinema(int id) {
39 return filmRepository.getFilmsFromCinema(id);
40 }
41
42}
Note: See TracBrowser for help on using the repository browser.