Changeset ef84238 for src/main/java/com/example/moviezone
- Timestamp:
- 02/10/23 11:18:48 (21 months ago)
- Branches:
- master
- Children:
- 04153a9
- Parents:
- 7926d68
- Location:
- src/main/java/com/example/moviezone
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/config/WebSecurityConfig.java
r7926d68 ref84238 33 33 .authorizeRequests() 34 34 .antMatchers("/","/films","/home/projections","/home/events","/home/getProjections/**","/home/films","/home/getFilm/**","/getFilm/**","/home/getEvent/**","/getEvent/**","/login","/events","/projections" ,"/home", "/assets/**", "/register", "/api/**").permitAll() 35 .antMatchers("/home/getSeats/**","/myTickets","/home/add Rating/**","/addRating/**","/getProjection/**","/home/makeReservation","/profileUser").hasRole("USER")35 .antMatchers("/home/getSeats/**","/myTickets","/home/addInterestedEvent/**","/home/deleteInterestedEvent/**","/home/addRating/**","/addRating/**","/getProjection/**","/home/makeReservation","/profileUser").hasRole("USER") 36 36 .antMatchers("/**").hasRole("ADMIN") 37 37 .anyRequest() -
src/main/java/com/example/moviezone/model/manytomany/CustomerIsInterestedInEvent.java
r7926d68 ref84238 25 25 @Id 26 26 @Column(name = "id_customer") 27 Integer id _customer;27 Integer idcustomer; 28 28 @Column(name = "id_event") 29 29 @Id 30 Integer id_event; 30 Integer idevent; 31 32 public CustomerIsInterestedInEvent(Integer id_customer, Integer id_event) { 33 this.idcustomer = id_customer; 34 this.idevent = id_event; 35 } 31 36 } -
src/main/java/com/example/moviezone/model/manytomany/CustomerIsInterestedInEventId.java
r7926d68 ref84238 7 7 @Data 8 8 public class CustomerIsInterestedInEventId implements Serializable { 9 Integer id _customer;10 Integer id _event;9 Integer idcustomer; 10 Integer idevent; 11 11 12 12 } -
src/main/java/com/example/moviezone/repository/CustomerIsInterestedInEventRepository.java
r7926d68 ref84238 8 8 @Repository 9 9 public interface CustomerIsInterestedInEventRepository extends JpaRepository<CustomerIsInterestedInEvent, CustomerIsInterestedInEventId> { 10 CustomerIsInterestedInEvent save(CustomerIsInterestedInEvent customerIsInterestedInEvent); 11 void delete(CustomerIsInterestedInEvent customerIsInterestedInEvent); 12 CustomerIsInterestedInEvent findFirstByIdeventAndAndIdcustomer(int id_event,int id_customer); 13 10 14 } -
src/main/java/com/example/moviezone/repository/EventRepository.java
r7926d68 ref84238 6 6 import org.springframework.data.jpa.repository.query.Procedure; 7 7 8 import javax.transaction.Transactional; 8 9 import java.util.List; 9 10 @Transactional 10 11 public interface EventRepository extends JpaRepository<Event,Integer> { 11 12 @Procedure("project.getEventsFromCinema") … … 13 14 @Procedure("project.getEventsFromNow") 14 15 List<Event> getFilmsFromCinemaNow(); 15 16 @Procedure("project.getEventsForCustomer") 17 List<Event> getEventsForCustomer(int id); 16 18 } -
src/main/java/com/example/moviezone/service/EventService.java
r7926d68 ref84238 1 1 package com.example.moviezone.service; 2 2 3 import ch.qos.logback.core.encoder.EchoEncoder; 3 4 import com.example.moviezone.model.Event; 4 5 … … 13 14 List<Event> getEventsFromCinema(int id); 14 15 Optional<Event> getEventById(Long id); 16 List<Event> getEventsForCustomer(int id); 15 17 } -
src/main/java/com/example/moviezone/service/Impl/EventServiceImpl.java
r7926d68 ref84238 43 43 return eventRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst(); 44 44 } 45 46 @Override 47 public List<Event> getEventsForCustomer(int id) { 48 return eventRepository.getEventsForCustomer(id); 49 } 45 50 } -
src/main/java/com/example/moviezone/web/HomeController.java
r7926d68 ref84238 24 24 import java.util.LinkedList; 25 25 import java.util.List; 26 import java.util.Objects;27 26 import java.util.stream.Collectors; 28 27 … … 46 45 private final CustomerService customerService; 47 46 private final Projection_RoomService projectionRoomService; 48 49 public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService, CinemaService cinemaService, CinemaOrganizesEventService cinemaOrganizesEventService, CinemaPlaysFilmService cinemaPlaysFilmService, ProjectionIsPlayedInRoomService projectionIsPlayedInRoomService, CategoryService categoryService, SeatService seatService, CustomerService customerService, Projection_RoomService projectionRoomService) 47 private final CustomerIsInterestedInEventService customerIsInterestedInEventService; 48 49 public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService, CinemaService cinemaService, CinemaOrganizesEventService cinemaOrganizesEventService, CinemaPlaysFilmService cinemaPlaysFilmService, ProjectionIsPlayedInRoomService projectionIsPlayedInRoomService, CategoryService categoryService, SeatService seatService, CustomerService customerService, Projection_RoomService projectionRoomService, CustomerIsInterestedInEventService customerIsInterestedInEventService) 50 50 { 51 51 … … 65 65 this.customerService = customerService; 66 66 this.projectionRoomService = projectionRoomService; 67 this.customerIsInterestedInEventService = customerIsInterestedInEventService; 67 68 } 68 69 … … 412 413 } 413 414 @GetMapping("/profileUser") 415 @Transactional 414 416 public String getUserProfile(Model model,HttpServletRequest request) 415 417 { 416 418 Customer customer=customerService.findByUsername(request.getRemoteUser()); 417 419 System.out.println(customer.getFirst_name()); 420 List<Event> events=eventService.getEventsForCustomer(customer.getId_user()); 418 421 model.addAttribute("customer",customer); 422 model.addAttribute("events",events); 419 423 model.addAttribute("bodyContent", "profileUser"); 420 424 return "master-template"; 421 425 } 426 @PostMapping("/addInterestedEvent/{id}") 427 public String addInterestedEvent(@PathVariable Long id,HttpServletRequest request, HttpServletResponse respons) 428 { 429 Customer customer=customerService.findByUsername(request.getRemoteUser()); 430 customerIsInterestedInEventService.add(customer.getId_user(),Integer.valueOf(id.intValue())); 431 return "redirect:/profileUser"; 432 } 433 @PostMapping("/deleteInterestedEvent/{id}") 434 public String deleteInterestedEvent(@PathVariable Long id,HttpServletRequest request, HttpServletResponse respons) 435 { 436 Customer customer=customerService.findByUsername(request.getRemoteUser()); 437 Event event=eventService.getEventById(id).get(); 438 customerIsInterestedInEventService.delete(customer,event); 439 return "redirect:/profileUser"; 440 } 422 441 }
Note:
See TracChangeset
for help on using the changeset viewer.