Ignore:
Timestamp:
02/08/23 11:18:57 (22 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
afa6544
Parents:
93341f8 (diff), 64ee7f4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://github.com/DenicaKj/MovieZone

Location:
src/main/java/com/example/moviezone
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/model/Seat.java

    r93341f8 r89438a3  
    1919    @ManyToOne
    2020    @JoinColumn(name = "id_room")
    21     Projection_Room projection_room;
     21    Projection_Room projection;
    2222    @ManyToOne
    2323    @JoinColumn(name = "id_category")
  • src/main/java/com/example/moviezone/model/procedures/FilmsReturnTable.java

    r93341f8 r89438a3  
    1818        this.name = name;
    1919    }
     20
     21    public Integer getId_film() {
     22        return id_film;
     23    }
     24
     25    public LocalDate getStart_date() {
     26        return start_date;
     27    }
     28
     29    public String getName() {
     30        return name;
     31    }
    2032}
  • src/main/java/com/example/moviezone/repository/FilmRepository.java

    r93341f8 r89438a3  
    77import org.springframework.data.repository.query.Param;
    88
     9import javax.transaction.Transactional;
    910import java.util.List;
    10 
     11@Transactional
    1112public interface FilmRepository extends JpaRepository<Film,Integer> {
    1213    @Procedure("project.getFilmsFromCinema")
  • src/main/java/com/example/moviezone/repository/ProjectionIsPlayedInRoomRepository.java

    r93341f8 r89438a3  
    44import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoomId;
    55import org.springframework.data.jpa.repository.JpaRepository;
     6import org.springframework.data.jpa.repository.Query;
     7import org.springframework.data.repository.query.Param;
    68
    79import java.util.List;
    810
    911public interface ProjectionIsPlayedInRoomRepository extends JpaRepository<ProjectionIsPlayedInRoom, ProjectionIsPlayedInRoomId> {
    10     List<ProjectionIsPlayedInRoom> findAllById_projection(Integer id_projection);
     12    @Query("SELECT pir FROM ProjectionIsPlayedInRoom pir WHERE pir.id_projection = :id_projection")
     13    List<ProjectionIsPlayedInRoom> findAllByProjectionId(@Param("id_projection") Integer id_projection);
    1114}
  • src/main/java/com/example/moviezone/repository/SeatRepository.java

    r93341f8 r89438a3  
    1010@Repository
    1111public interface SeatRepository extends JpaRepository<Seat,Integer> {
    12     List<Seat> findAllByProjection_room(Projection_Room projection_room);
     12    List<Seat> findAllByProjection(Projection_Room projection);
    1313}
  • src/main/java/com/example/moviezone/service/FilmService.java

    r93341f8 r89438a3  
    22
    33import com.example.moviezone.model.Film;
     4import com.example.moviezone.model.procedures.FilmsReturnTable;
    45
    56import java.time.LocalDate;
     
    1213              String age_category, String url, String director, LocalDate start_date,LocalDate end_date);
    1314    Optional<Film> getFilmById(Long id);
     15    List<FilmsReturnTable> getFilmsFromCinema(int id);
    1416}
  • src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java

    r93341f8 r89438a3  
    22
    33import com.example.moviezone.model.Film;
     4import com.example.moviezone.model.procedures.FilmsReturnTable;
    45import com.example.moviezone.repository.FilmRepository;
    56import com.example.moviezone.service.FilmService;
     
    3435    }
    3536
     37    @Override
     38    public List<FilmsReturnTable> getFilmsFromCinema(int id) {
     39        return filmRepository.getFilmsFromCinema(id);
     40    }
     41
    3642}
  • src/main/java/com/example/moviezone/service/Impl/ProjectionIsPlayedInRoomServiceImpl.java

    r93341f8 r89438a3  
    11package com.example.moviezone.service.Impl;
    22
     3import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
    34import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
    45import com.example.moviezone.service.ProjectionIsPlayedInRoomService;
    56import org.springframework.stereotype.Service;
     7
     8import java.util.List;
     9import java.util.Optional;
    610
    711@Service
     
    1317    }
    1418
     19    @Override
     20    public List<ProjectionIsPlayedInRoom> getProjectionPlayedInRoom(Integer id) {
     21        return projectionIsPlayedInRoomRepository.findAllByProjectionId(id);
     22    }
    1523}
  • src/main/java/com/example/moviezone/service/Impl/SeatServiceImpl.java

    r93341f8 r89438a3  
    2424    @Override
    2525    public List<Seat> findAllByProjection_Room(Projection_Room projection_room) {
    26         return seatRepository.findAllByProjection_room(projection_room);
     26        return seatRepository.findAllByProjection(projection_room);
    2727    }
    2828}
  • src/main/java/com/example/moviezone/service/ProjectionIsPlayedInRoomService.java

    r93341f8 r89438a3  
    11package com.example.moviezone.service;
    22
     3import com.example.moviezone.model.Film;
     4import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
     5
     6import java.util.List;
     7import java.util.Optional;
     8
    39public interface ProjectionIsPlayedInRoomService {
    4 
     10    List<ProjectionIsPlayedInRoom> getProjectionPlayedInRoom(Integer id);
    511
    612}
  • src/main/java/com/example/moviezone/web/HomeController.java

    r93341f8 r89438a3  
    44import com.example.moviezone.model.*;
    55import com.example.moviezone.model.exceptions.PasswordsDoNotMatchException;
     6
    67import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
    78import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
     9
     10import com.example.moviezone.model.procedures.FilmsReturnTable;
     11
    812import com.example.moviezone.service.*;
    913import org.springframework.format.annotation.DateTimeFormat;
     
    1418import javax.servlet.http.HttpSession;
    1519import java.time.LocalDate;
     20import java.util.LinkedList;
    1621import java.util.List;
    1722import java.util.stream.Collectors;
     
    3136private final CinemaOrganizesEventService cinemaOrganizesEventService;
    3237private final CinemaPlaysFilmService cinemaPlaysFilmService;
    33 private final ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository;
    34 
    35 
    36     public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService, CinemaService cinemaService, CinemaOrganizesEventService cinemaOrganizesEventService, CinemaPlaysFilmService cinemaPlaysFilmService, ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository) {
     38private final ProjectionIsPlayedInRoomService projectionIsPlayedInRoomService;
     39
     40
     41    public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService, CinemaService cinemaService, CinemaOrganizesEventService cinemaOrganizesEventService, CinemaPlaysFilmService cinemaPlaysFilmService, ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository)
     42    {
    3743
    3844        this.filmService = filmService;
     
    4652        this.cinemaOrganizesEventService = cinemaOrganizesEventService;
    4753        this.cinemaPlaysFilmService = cinemaPlaysFilmService;
    48         this.projectionIsPlayedInRoomRepository = projectionIsPlayedInRoomRepository;
     54        this.projectionIsPlayedInRoomService = projectionIsPlayedInRoomService;
    4955    }
    5056
     
    127133
    128134    }
    129 
    130135    @GetMapping("/films")
    131136    public String getFilmsPage(Model model){
    132137        model.addAttribute("cinemas",cinemaService.findAllCinemas());
    133         model.addAttribute("films",filmService.findAllFilms());
     138            List<FilmsReturnTable> pom=new LinkedList<>();
     139            model.addAttribute("films",pom);
     140            boolean h=pom.isEmpty();
     141            List<FilmsReturnTable> help=filmService.getFilmsFromCinema(2);
    134142        model.addAttribute("bodyContent","films");
    135143        return "master-template";
    136144    }
    137145
     146    public String getFilmsPage1(Model model,Integer id_cinema){
     147        model.addAttribute("cinemas",cinemaService.findAllCinemas());
     148        if (id_cinema!=null) {
     149            model.addAttribute("films",filmService.getFilmsFromCinema(id_cinema.intValue()));
     150        }else{
     151            List<FilmsReturnTable> pom=new LinkedList<>();
     152            model.addAttribute("films",pom);
     153        }
     154
     155        model.addAttribute("bodyContent","films");
     156        return "master-template";
     157    }
     158    @PostMapping("/getFilmsFromCinema")
     159    public String getFilmsFromCinema(@RequestParam Integer cinema, Model model){
     160        return getFilmsPage1(model,cinema);
     161    }
    138162    @GetMapping("/projections")
    139163    public String getProjectionsPage(Model model)
     
    262286
    263287
    264         List<ProjectionIsPlayedInRoom> p= projectionIsPlayedInRoomRepository.findAllById_projection(id_projection);
     288        List<ProjectionIsPlayedInRoom> p= projectionIsPlayedInRoomService.getProjectionPlayedInRoom(id_projection);
    265289
    266290        model.addAttribute("projection",projection);
Note: See TracChangeset for help on using the changeset viewer.