Changeset 73f0dbc for src


Ignore:
Timestamp:
02/10/23 01:18:53 (21 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
7926d68
Parents:
01a1ca6
Message:

added rating

Location:
src/main
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/config/WebSecurityConfig.java

    r01a1ca6 r73f0dbc  
    3232        http.csrf().disable()
    3333                .authorizeRequests()
    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")
     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/addRating/**","/addRating/**","/getProjection/**","/home/makeReservation").hasRole("USER")
    3636                .antMatchers("/**").hasRole("ADMIN")
    3737                .anyRequest()
  • src/main/java/com/example/moviezone/model/manytomany/CustomerRatesFilm.java

    r01a1ca6 r73f0dbc  
    3030    Integer id_film;
    3131
     32    double rating;
     33
     34    public CustomerRatesFilm(Integer id_customer, Integer id_film, double rating) {
     35        this.id_customer = id_customer;
     36        this.id_film = id_film;
     37        this.rating = rating;
     38    }
    3239}
  • src/main/java/com/example/moviezone/repository/CustomerRatesFilmRepository.java

    r01a1ca6 r73f0dbc  
    1212@Procedure("project.avg_rating1")
    1313    double avg_rating(int id);
    14 
     14    CustomerRatesFilm save(CustomerRatesFilm customerRatesFilm);
    1515}
  • src/main/java/com/example/moviezone/service/CustomerRatesFilmService.java

    r01a1ca6 r73f0dbc  
    11package com.example.moviezone.service;
     2
     3import com.example.moviezone.model.Customer;
     4import com.example.moviezone.model.manytomany.CustomerRatesFilm;
    25
    36public interface CustomerRatesFilmService {
    47    double avg_rating(int id);
     8    CustomerRatesFilm addRating(Integer id_customer, Integer id_film, double rating);
     9
    510}
  • src/main/java/com/example/moviezone/service/Impl/CustomerRatesFilmImpl.java

    r01a1ca6 r73f0dbc  
    11package com.example.moviezone.service.Impl;
    22
     3import com.example.moviezone.model.manytomany.CustomerRatesFilm;
    34import com.example.moviezone.repository.CustomerRatesFilmRepository;
    45import com.example.moviezone.service.CustomerRatesFilmService;
     
    1718        return customerRatesFilmRepository.avg_rating(id);
    1819    }
     20
     21    @Override
     22    public CustomerRatesFilm addRating(Integer id_customer, Integer id_film, double rating) {
     23        CustomerRatesFilm customerRatesFilm=new CustomerRatesFilm(id_customer,id_film,rating);
     24        return customerRatesFilmRepository.save(customerRatesFilm);
     25    }
    1926}
  • src/main/java/com/example/moviezone/web/HomeController.java

    r01a1ca6 r73f0dbc  
    395395        return "redirect:/myTickets";
    396396    }
     397    @PostMapping("/addRating/{id}")
     398    public String addRating(@RequestParam Long rate,@PathVariable Long id,HttpServletRequest request, HttpServletResponse respons)
     399    {
     400        Customer customer=customerService.findByUsername(request.getRemoteUser());
     401        System.out.println(customer.getFirst_name());
     402        customerRatesFilmService.addRating(customer.getId_user(),Integer.valueOf(id.intValue()),Integer.valueOf(rate.intValue()));
     403        return "redirect:/home/getFilm/"+id;
     404    }
    397405
    398406}
  • src/main/resources/templates/film.html

    r01a1ca6 r73f0dbc  
    2424        border-radius: 20px;
    2525    }
     26    .button {
     27        top:250px;
     28        background-color: #ff5019;
     29        border: none;
     30        color: black;
     31        padding: 10px 20px;
     32        text-align: center;
     33        text-decoration: none;
     34        display: inline-block;
     35        font-size: 16px;
     36        border-radius: 20px;
     37    }
     38    .form-group{
     39        width: 200px;
     40    }
    2641</style>
    2742<div xmlns:th="http://www.thymeleaf.org">
     
    4762                <span>/5</span>
    4863            </h4>
     64            <form th:action="@{'/home/addRating/{id}' (id=${film.id_film})}"
     65                  th:method="POST">
     66                <div class="form-group">
     67                    <label style="color: black;font-size: 20px;font-weight: bold">Оцени:</label>
     68                <input required type="text" id="rate" name="rate">
     69                </div>
     70                <button class="button" type="submit">Додади Оцена</button>
     71            </form>
    4972        </div>
    5073    <div class="slika">
  • src/main/resources/templates/myTickets.html

    r01a1ca6 r73f0dbc  
    5454                        <form th:action="@{'/home/getSeats/{id}' (id=${ticket.id_ticket})}"
    5555                              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>
     56                            <--button th:if="${ticket.projection.date_time_start != null and #dates.isBefore(java.time.LocalDateTime.of(ticket.projection.date_time_start, java.time.LocalTime.MIN).toInstant(java.time.ZoneOffset.UTC).toEpochMilli(), java.util.Date.from(java.time.LocalDate.now().atStartOfDay(java.time.ZoneId.systemDefault()).toInstant()).getTime())}" class="button" type="submit">Откажи</--button>
    5757                        </form>
    5858
Note: See TracChangeset for help on using the changeset viewer.