- Timestamp:
- 02/07/23 23:14:46 (22 months ago)
- Branches:
- master
- Children:
- 64ee7f4
- Parents:
- cb5debb
- Location:
- src/main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/model/procedures/FilmsReturnTable.java
rcb5debb r8d49568 18 18 this.name = name; 19 19 } 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 } 20 32 } -
src/main/java/com/example/moviezone/repository/FilmRepository.java
rcb5debb r8d49568 7 7 import org.springframework.data.repository.query.Param; 8 8 9 import javax.transaction.Transactional; 9 10 import java.util.List; 10 11 @Transactional 11 12 public interface FilmRepository extends JpaRepository<Film,Integer> { 12 13 @Procedure("project.getFilmsFromCinema") -
src/main/java/com/example/moviezone/service/FilmService.java
rcb5debb r8d49568 2 2 3 3 import com.example.moviezone.model.Film; 4 import com.example.moviezone.model.procedures.FilmsReturnTable; 4 5 5 6 import java.time.LocalDate; … … 12 13 String age_category, String url, String director, LocalDate start_date,LocalDate end_date); 13 14 Optional<Film> getFilmById(Long id); 15 List<FilmsReturnTable> getFilmsFromCinema(int id); 14 16 } -
src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java
rcb5debb r8d49568 2 2 3 3 import com.example.moviezone.model.Film; 4 import com.example.moviezone.model.procedures.FilmsReturnTable; 4 5 import com.example.moviezone.repository.FilmRepository; 5 6 import com.example.moviezone.service.FilmService; … … 34 35 } 35 36 37 @Override 38 public List<FilmsReturnTable> getFilmsFromCinema(int id) { 39 return filmRepository.getFilmsFromCinema(id); 40 } 41 36 42 } -
src/main/java/com/example/moviezone/web/HomeController.java
rcb5debb r8d49568 4 4 import com.example.moviezone.model.*; 5 5 import com.example.moviezone.model.exceptions.PasswordsDoNotMatchException; 6 6 7 import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom; 7 8 import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository; 9 10 import com.example.moviezone.model.procedures.FilmsReturnTable; 11 8 12 import com.example.moviezone.service.*; 9 13 import org.springframework.format.annotation.DateTimeFormat; … … 14 18 import javax.servlet.http.HttpSession; 15 19 import java.time.LocalDate; 20 import java.util.LinkedList; 16 21 import java.util.List; 17 22 import java.util.stream.Collectors; … … 35 40 36 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) { 37 42 38 43 this.filmService = filmService; 39 44 this.userService = userService; … … 127 132 128 133 } 129 130 134 @GetMapping("/films") 131 135 public String getFilmsPage(Model model){ 132 136 model.addAttribute("cinemas",cinemaService.findAllCinemas()); 133 model.addAttribute("films",filmService.findAllFilms()); 137 List<FilmsReturnTable> pom=new LinkedList<>(); 138 model.addAttribute("films",pom); 139 boolean h=pom.isEmpty(); 140 List<FilmsReturnTable> help=filmService.getFilmsFromCinema(2); 134 141 model.addAttribute("bodyContent","films"); 135 142 return "master-template"; 136 143 } 137 144 145 public String getFilmsPage1(Model model,Integer id_cinema){ 146 model.addAttribute("cinemas",cinemaService.findAllCinemas()); 147 if (id_cinema!=null) { 148 model.addAttribute("films",filmService.getFilmsFromCinema(id_cinema.intValue())); 149 }else{ 150 List<FilmsReturnTable> pom=new LinkedList<>(); 151 model.addAttribute("films",pom); 152 } 153 154 model.addAttribute("bodyContent","films"); 155 return "master-template"; 156 } 157 @PostMapping("/getFilmsFromCinema") 158 public String getFilmsFromCinema(@RequestParam Integer cinema, Model model){ 159 return getFilmsPage1(model,cinema); 160 } 138 161 @GetMapping("/projections") 139 162 public String getProjectionsPage(Model model) -
src/main/resources/templates/films.html
rcb5debb r8d49568 200 200 </style> 201 201 <div> 202 <form th:action="@{'/home/getFilm/{id}' (id=${film.getId_film()})}" 203 th:method="POST"> 204 202 205 <div class="form-group"> 203 206 <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"> 205 208 <option 206 209 th:selected="${cinemas.get(1)}" … … 210 213 </option> 211 214 </select> 215 212 216 </div> 217 <button class="button" type="submit">Filter</button> 218 </form> 213 219 214 220 </div> 215 221 <div xmlns:th="http://www.thymeleaf.org"> 216 222 <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"> 242 225 <div class="card"> 243 226 <div class="imgBx"> 244 <img th:src=" @{${film.getUrl()}}"/>227 <img th:src=""/> 245 228 </div> 246 229 <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> 251 236 </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()})}" 257 239 th:method="GET"> 258 240 <button class="button" type="submit">Details</button>
Note:
See TracChangeset
for help on using the changeset viewer.