- Timestamp:
- 02/10/23 00:10:41 (21 months ago)
- Branches:
- master
- Children:
- 73f0dbc
- Parents:
- 5444409
- Location:
- src/main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/config/WebSecurityConfig.java
r5444409 r01a1ca6 32 32 http.csrf().disable() 33 33 .authorizeRequests() 34 .antMatchers("/","/**","/home/getFilm/**","/films","/projections" ,"/home", "/assets/**", "/register", "/api/**").permitAll() 35 .antMatchers("/admin/**").hasRole("ADMIN") 34 .antMatchers("/","/films","/home/projections","/home/events","/home/getProjections/**","/home/films","/getFilm/**","/getEvent/**","/login","/events","/projections" ,"/home", "/assets/**", "/register", "/api/**").permitAll() 35 .antMatchers("/home/getSeats/**","/myTickets","/getProjection/**","/home/makeReservation").hasRole("USER") 36 .antMatchers("/**").hasRole("ADMIN") 36 37 .anyRequest() 37 38 .authenticated() -
src/main/java/com/example/moviezone/repository/CustomerRepository.java
r5444409 r01a1ca6 7 7 @Repository 8 8 public interface CustomerRepository extends JpaRepository<Customer,Integer> { 9 Customer getByUsername(String username); 9 10 } -
src/main/java/com/example/moviezone/service/CustomerService.java
r5444409 r01a1ca6 11 11 List<Customer> findAllCustomers(); 12 12 Optional<Customer> getCustomerById(int id); 13 Customer findByUsername(String username); 13 14 } -
src/main/java/com/example/moviezone/service/Impl/CustomerServiceImpl.java
r5444409 r01a1ca6 26 26 return customerRepository.findById(id); 27 27 } 28 29 @Override 30 public Customer findByUsername(String username) { 31 return customerRepository.getByUsername(username); 32 } 28 33 } -
src/main/java/com/example/moviezone/web/HomeController.java
r5444409 r01a1ca6 259 259 } 260 260 @GetMapping("/myTickets") 261 public String getMyTicketsPage(Model model,HttpSession session) 262 { 263 model.addAttribute("tickets",ticketService.findAllByCustomer((Customer) session.getAttribute("user"))); 261 public String getMyTicketsPage(Model model,HttpServletRequest request) 262 { 263 Customer customer=customerService.findByUsername(request.getRemoteUser()); 264 model.addAttribute("tickets",ticketService.findAllByCustomer(customer)); 264 265 model.addAttribute("bodyContent","myTickets"); 265 266 return "master-template"; … … 380 381 @PostMapping("/makeReservation") 381 382 @Transactional 382 public String createTicketForReservation(@RequestParam Long film,@RequestParam Long projection,@RequestParam Long id_seat,@RequestParam String discount )383 public String createTicketForReservation(@RequestParam Long film,@RequestParam Long projection,@RequestParam Long id_seat,@RequestParam String discount,HttpServletRequest request, HttpServletResponse respons) 383 384 { 384 385 Ticket t; 386 Customer customer=customerService.findByUsername(request.getRemoteUser()); 385 387 Projection projection1=projectionService.findById(projection.intValue()); 386 388 if(projection1.getDiscount().equals(discount)){ 387 t=ticketService.saveWithDiscount(LocalDate.now(),customer Service.getCustomerById(2).get(),projection1,projection1.getDiscount(),seatService.getSeatById(id_seat.intValue()).get());389 t=ticketService.saveWithDiscount(LocalDate.now(),customer,projection1,projection1.getDiscount(),seatService.getSeatById(id_seat.intValue()).get()); 388 390 }else{ 389 t=ticketService.saveWithout(LocalDate.now(),customer Service.getCustomerById(4).get(),projection1,seatService.getSeatById(id_seat.intValue()).get());391 t=ticketService.saveWithout(LocalDate.now(),customer,projection1,seatService.getSeatById(id_seat.intValue()).get()); 390 392 } 391 393 Integer price=ticketService.priceForTicket(t.getId_ticket()); 392 394 t.setPrice(price); 393 return "redirect:/ home";395 return "redirect:/myTickets"; 394 396 } 395 397 -
src/main/resources/templates/myTickets.html
r5444409 r01a1ca6 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 </head> 7 <body> 1 <style> 2 .card-horizontal { 3 display: flex; 4 flex: 1 1 auto; 5 } 6 .card { 7 transition: all .2s ease-in-out; 8 } 9 .card:hover { 10 transform: scale(1.05); 11 } 12 .button { 13 top:250px; 14 background-color: #ff5019; 15 border: none; 16 color: black; 17 padding: 10px 20px; 18 text-align: center; 19 text-decoration: none; 20 display: inline-block; 21 font-size: 16px; 22 border-radius: 20px; 23 } 24 .form-group{ 25 width: 200px; 26 } 27 </style> 28 <div style="border-radius:30px" > 29 <div class="row"> 30 <div class="col-12 mt-3" style="padding-left:100px;height:75%;"> 31 <div class="card" th:each="ticket : ${tickets}" style=" border-radius: 30px;width:92%;align-self:center"> 32 <div class="card-horizontal" > 33 <div class="card-body"> 8 34 9 </body> 10 </html> 35 <h4 class="card-title" > 36 <div> 37 <span>Филм:</span> 38 <span th:text="${ticket.projection.film.name}"></span></div> 39 <div> 40 <span>Почеток на проекција: </span> 41 <span th:text="${ticket.projection.date_time_start}"></span></div> 42 <div> 43 <span>Крај на проекција: </span> 44 <span th:text="${ticket.projection.date_time_end}"></span></div> 45 </h4> 46 47 <p class="card-text" th:text="${ticket.projection.type_of_technology}"></p> 48 <span>Број на седиште: </span><p class="card-text" th:text="${ticket.seat.seat_number}"></p> 49 <span>Цена: </span><p class="card-text" th:text="${ticket.price}"></p> 50 </div> 51 </div> 52 <div class="card-footer" style="border-bottom-right-radius:30px;border-bottom-left-radius:30px"> 53 <small> 54 <form th:action="@{'/home/getSeats/{id}' (id=${ticket.id_ticket})}" 55 th:method="GET"> 56 <--button th:if="${ticket.projection.date_time_start != null and ticket.projection.date_time_start.isBefore(java.time.LocalDate.now())}" class="button" type="submit">Откажи</--button> 57 </form> 58 59 </small> 60 </div> 61 </div> 62 </div> 63 </div> 64 </div>
Note:
See TracChangeset
for help on using the changeset viewer.