Changeset 89438a3 for src/main


Ignore:
Timestamp:
02/08/23 11:18:57 (23 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
Files:
12 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);
  • src/main/resources/templates/films.html

    r93341f8 r89438a3  
    200200</style>
    201201<div>
     202    <form th:action="@{'/home/getFilm/{id}' (id=${film.getId_film()})}"
     203          th:method="POST">
     204
    202205    <div class="form-group">
    203206        <label style="color: white;font-size: 20px;font-weight: bold">Кино</label>
    204         <select name="cinemas" class="form-control">
     207        <select name="cinemas" class="form-control" id="cinema">
    205208            <option
    206209                    th:selected="${cinemas.get(1)}"
     
    210213            </option>
    211214        </select>
     215
    212216    </div>
     217        <button class="button" type="submit">Filter</button>
     218</form>
    213219
    214220</div>
    215221<div xmlns:th="http://www.thymeleaf.org">
    216222    <div class="main">
    217 <!--        <div th:each="film : ${films}" class="container">-->
    218 <!--            <div class="card">-->
    219 <!--                <div class="imgBx">-->
    220 <!--                    <img th:src="@{${film.getUrl()}}"/>-->
    221 <!--                </div>-->
    222 <!--                <div class="contentBx">-->
    223 <!--                    <h2  th:text="${film.getName()}"></h2>-->
    224 <!--                    <div class="size">-->
    225 <!--                        <h3>Duration :</h3>-->
    226 <!--                        <span th:text="${film.getDuration()}"></span>-->
    227 <!--                    </div>-->
    228 <!--                    <div class="color">-->
    229 <!--                        <h3>Genre:</h3>-->
    230 <!--                        <span th:text="${film.getGenre()}"></span>-->
    231 <!--                    </div>-->
    232 <!--                    <form th:action="@{'/home/getFilm/{id}' (id=${film.getId_film()})}"-->
    233 <!--                          th:method="GET">-->
    234 <!--                        <button class="button" type="submit">Details</button>-->
    235 <!--                    </form>-->
    236 
    237 
    238 <!--                </div>-->
    239 <!--            </div>-->
    240 <!--        </div>-->
    241         <div th:each="film : ${films}" class="container">
     223        <div    th:if="${films.isEmpty()} == false"
     224                th:each="film : ${films}" class="container">
    242225            <div class="card">
    243226                <div class="imgBx">
    244                     <img th:src="@{${film.getUrl()}}"/>
     227                    <img th:src=""/>
    245228                </div>
    246229                <div class="contentBx">
    247                     <h2  th:text="${film.getName()}"></h2>
    248                     <div class="size">
    249                         <h3>Duration :</h3>
    250                         <span th:text="${film.getDuration()}"></span>
     230                    <h2  th:if="${films.isEmpty()} == false"
     231                            th:text="${film.getName()}"></h2>
     232                    <div class="color">
     233                        <h3>Start Date:</h3>
     234                        <span th:if="${films.isEmpty()} == false"
     235                                th:text="${film.getStart_date()}"></span>
    251236                    </div>
    252                     <div class="color">
    253                         <h3>Genre:</h3>
    254                         <span th:text="${film.getGenre()}"></span>
    255                     </div>
    256                     <form th:action="@{'/home/getFilm/{id}' (id=${film.getId_film()})}"
     237                    <form th:if="${films.isEmpty()} == false"
     238                            th:action="@{'/home/getFilm/{id}' (id=${film.getId_film()})}"
    257239                          th:method="GET">
    258240                        <button class="button" type="submit">Details</button>
Note: See TracChangeset for help on using the changeset viewer.