[11dea8f] | 1 | package com.example.moviezone.service.Impl;
|
---|
| 2 |
|
---|
| 3 | import com.example.moviezone.model.Event;
|
---|
[1b248e4] | 4 | import com.example.moviezone.repository.EventRepository;
|
---|
[11dea8f] | 5 | import com.example.moviezone.service.EventService;
|
---|
| 6 | import org.springframework.stereotype.Service;
|
---|
| 7 |
|
---|
[302b233] | 8 | import java.time.LocalDate;
|
---|
[90317ea] | 9 | import java.util.Collections;
|
---|
[11dea8f] | 10 | import java.util.List;
|
---|
[90317ea] | 11 | import java.util.Optional;
|
---|
[11dea8f] | 12 |
|
---|
| 13 | @Service
|
---|
| 14 | public class EventServiceImpl implements EventService {
|
---|
[1b248e4] | 15 | private final EventRepository eventRepository;
|
---|
| 16 |
|
---|
| 17 | public EventServiceImpl(EventRepository eventRepository) {
|
---|
| 18 | this.eventRepository = eventRepository;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
[11dea8f] | 21 | @Override
|
---|
| 22 | public List<Event> findAllEvents() {
|
---|
[1b248e4] | 23 | return eventRepository.findAll();
|
---|
[11dea8f] | 24 | }
|
---|
[302b233] | 25 |
|
---|
| 26 | @Override
|
---|
[0fb69cc] | 27 | public Event save(LocalDate start_date, String theme, String duration, String repeating,String img_url) {
|
---|
| 28 | return eventRepository.save(new Event(theme,duration,repeating,start_date,img_url));
|
---|
[302b233] | 29 | }
|
---|
[90317ea] | 30 |
|
---|
| 31 | @Override
|
---|
| 32 | public List<Event> getEventsNow() {
|
---|
| 33 | return eventRepository.getFilmsFromCinemaNow();
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | @Override
|
---|
| 37 | public List<Event> getEventsFromCinema(int id) {
|
---|
| 38 | return eventRepository.getFilmsFromCinema(id);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | @Override
|
---|
| 42 | public Optional<Event> getEventById(Long id) {
|
---|
| 43 | return eventRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();
|
---|
| 44 | }
|
---|
[ef84238] | 45 |
|
---|
| 46 | @Override
|
---|
| 47 | public List<Event> getEventsForCustomer(int id) {
|
---|
| 48 | return eventRepository.getEventsForCustomer(id);
|
---|
| 49 | }
|
---|
[11dea8f] | 50 | }
|
---|