Changeset 43a1688 for src/main


Ignore:
Timestamp:
02/06/23 15:13:02 (23 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
f9cc555
Parents:
f8ef9bd
Message:

I CALLED A PROCEDURE FROM SPRING

Location:
src/main
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/repository/CustomerRatesFilmRepository.java

    rf8ef9bd r43a1688  
    44import com.example.moviezone.model.manytomany.CustomerRatesFilmId;
    55import org.springframework.data.jpa.repository.JpaRepository;
     6import org.springframework.data.jpa.repository.query.Procedure;
     7import org.springframework.data.repository.query.Param;
    68import org.springframework.stereotype.Repository;
    79
    810@Repository
    911public interface CustomerRatesFilmRepository extends JpaRepository<CustomerRatesFilm, CustomerRatesFilmId> {
     12@Procedure("project.avg_rating1")
     13    double avg_rating(int id);
     14
    1015}
  • src/main/java/com/example/moviezone/web/HomeController.java

    rf8ef9bd r43a1688  
    1515import java.time.LocalDate;
    1616import java.util.List;
    17 import java.util.Optional;
    1817import java.util.stream.Collectors;
    1918
     
    2827private final TicketService ticketService;
    2928private final WorkerService workerService;
     29private final CustomerRatesFilmService customerRatesFilmService;
    3030
    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) {
    3232        this.filmService = filmService;
    3333        this.userService = userService;
     
    3636        this.ticketService = ticketService;
    3737        this.workerService = workerService;
     38        this.customerRatesFilmService = customerRatesFilmService;
    3839    }
    3940
     
    4950    @GetMapping("/getFilm/{id}")
    5051    public String getFilm(@PathVariable Long id, Model model) {
    51         Optional<Film> film=filmService.getFilmById(id);
     52        Film film=filmService.getFilmById(id).get();
    5253        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");
    5458
    5559        return "master-template";
  • src/main/resources/templates/film.html

    rf8ef9bd r43a1688  
    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    .genres{
     3        width: 100px;
     4        text-align: center;
     5        background-color: #ff5019;
     6        border-radius: 20px;
     7        color: #111111;
     8        font-size: 20px;
     9        font-weight: 200;
     10        margin: 20px;
     11    }
     12    .main{
     13        display: flex;
     14        justify-content: flex-start;
     15        align-items: flex-start;
     16        margin-left: 100px;
     17    }
     18</style>
     19<div xmlns:th="http://www.thymeleaf.org">
     20<div class="main">
     21        <div class="container-1">
     22            <h1 style="color: white; font-weight: 600" class="name" th:text="${film.getName()}">
     23            </h1>
     24            <div th:each="genre : ${genres}" class="genres">
     25                <span th:text="${genre}"></span>
     26            </div>
    827
    9 </body>
    10 </html>
     28        </div>
     29
     30</div>
     31</div>
     32</div>
Note: See TracChangeset for help on using the changeset viewer.