Changeset 43a1688 for src/main/java
- Timestamp:
- 02/06/23 15:13:02 (23 months ago)
- Branches:
- master
- Children:
- f9cc555
- Parents:
- f8ef9bd
- Location:
- src/main/java/com/example/moviezone
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/repository/CustomerRatesFilmRepository.java
rf8ef9bd r43a1688 4 4 import com.example.moviezone.model.manytomany.CustomerRatesFilmId; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.query.Procedure; 7 import org.springframework.data.repository.query.Param; 6 8 import org.springframework.stereotype.Repository; 7 9 8 10 @Repository 9 11 public interface CustomerRatesFilmRepository extends JpaRepository<CustomerRatesFilm, CustomerRatesFilmId> { 12 @Procedure("project.avg_rating1") 13 double avg_rating(int id); 14 10 15 } -
src/main/java/com/example/moviezone/web/HomeController.java
rf8ef9bd r43a1688 15 15 import java.time.LocalDate; 16 16 import java.util.List; 17 import java.util.Optional;18 17 import java.util.stream.Collectors; 19 18 … … 28 27 private final TicketService ticketService; 29 28 private final WorkerService workerService; 29 private final CustomerRatesFilmService customerRatesFilmService; 30 30 31 public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService ) {31 public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService) { 32 32 this.filmService = filmService; 33 33 this.userService = userService; … … 36 36 this.ticketService = ticketService; 37 37 this.workerService = workerService; 38 this.customerRatesFilmService = customerRatesFilmService; 38 39 } 39 40 … … 49 50 @GetMapping("/getFilm/{id}") 50 51 public String getFilm(@PathVariable Long id, Model model) { 51 Optional<Film> film=filmService.getFilmById(id);52 Film film=filmService.getFilmById(id).get(); 52 53 model.addAttribute("film", film); 53 model.addAttribute("bodyContent", "home"); 54 List<String> genres= List.of(film.getGenre().split(",")); 55 double r=customerRatesFilmService.avg_rating(film.getId_film()); 56 model.addAttribute("genres", genres); 57 model.addAttribute("bodyContent", "film"); 54 58 55 59 return "master-template";
Note:
See TracChangeset
for help on using the changeset viewer.