Changeset 01a1ca6 for src/main/java
- Timestamp:
- 02/10/23 00:10:41 (23 months ago)
- Branches:
- master
- Children:
- 73f0dbc
- Parents:
- 5444409
- Location:
- src/main/java/com/example/moviezone
- Files:
-
- 5 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
Note:
See TracChangeset
for help on using the changeset viewer.