Changeset eb5426c for src


Ignore:
Timestamp:
02/06/23 03:59:41 (22 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
f8ef9bd
Parents:
448bd84
Message:

Home Page

Location:
src/main
Files:
2 added
12 edited

Legend:

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

    r448bd84 reb5426c  
    3232        http.csrf().disable()
    3333                .authorizeRequests()
    34                 .antMatchers("/", "/home", "/assets/**", "/register", "/api/**").permitAll()
     34                .antMatchers("/","/home/getFilm/**", "/home", "/assets/**", "/register", "/api/**").permitAll()
    3535                .antMatchers("/admin/**").hasRole("ADMIN")
    3636                .anyRequest()
  • src/main/java/com/example/moviezone/model/Film.java

    r448bd84 reb5426c  
    4646
    4747    }
     48
     49    public Integer getId_film() {
     50        return id_film;
     51    }
     52
     53    public String getName() {
     54        return name;
     55    }
     56
     57    public Integer getDuration() {
     58        return duration;
     59    }
     60
     61    public String getActors() {
     62        return actors;
     63    }
     64
     65    public String getGenre() {
     66        return genre;
     67    }
     68
     69    public String getAge_category() {
     70        return age_category;
     71    }
     72
     73    public String getUrl() {
     74        return url;
     75    }
     76
     77    public String getDirector() {
     78        return director;
     79    }
     80
     81    public LocalDate getStart_date() {
     82        return start_date;
     83    }
     84
     85    public LocalDate getEnd_date() {
     86        return end_date;
     87    }
    4888}
  • src/main/java/com/example/moviezone/model/Projection.java

    r448bd84 reb5426c  
    3939        this.film = film;
    4040    }
     41
     42    public Projection() {
     43    }
    4144}
  • src/main/java/com/example/moviezone/repository/FilmRepository.java

    r448bd84 reb5426c  
    33import com.example.moviezone.model.Film;
    44import org.springframework.data.jpa.repository.JpaRepository;
     5import org.springframework.data.jpa.repository.query.Procedure;
     6import org.springframework.data.repository.query.Param;
     7
     8import java.util.List;
    59
    610public interface FilmRepository extends JpaRepository<Film,Integer> {
     11
    712}
  • src/main/java/com/example/moviezone/repository/ProjectionRepository.java

    r448bd84 reb5426c  
    99public interface ProjectionRepository extends JpaRepository<Projection,Integer> {
    1010    //    NOTE: CHANGE THIS WITH MATERIALIZED VIEW
    11     List<Projection> findAllByDate_time_startBefore(LocalDate datum);
     11    //List<Projection> findAllBydate_time_startBefore(LocalDate datum);
    1212}
  • src/main/java/com/example/moviezone/service/FilmService.java

    r448bd84 reb5426c  
    55import java.time.LocalDate;
    66import java.util.List;
     7import java.util.Optional;
    78
    89public interface FilmService {
     
    1011    Film save(String name, Integer duration, String actors, String genre,
    1112              String age_category, String url, String director, LocalDate start_date,LocalDate end_date);
     13    Optional<Film> getFilmById(Long id);
    1214}
  • src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java

    r448bd84 reb5426c  
    77
    88import java.time.LocalDate;
     9import java.util.Collections;
    910import java.util.List;
     11import java.util.Optional;
    1012
    1113@Service
     
    2628        return filmRepository.save(new Film(name,duration,actors,genre,age_category,url,director,start_date,end_date));
    2729    }
     30
     31    @Override
     32    public Optional<Film> getFilmById(Long id) {
     33        return filmRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();
     34    }
     35
    2836}
  • src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java

    r448bd84 reb5426c  
    2525    }
    2626
    27     @Override
    28     public List<Projection> findAllAvailableProjections(LocalDate date) {
    29         return projectionRepository.findAllByDate_time_startBefore(date);
    30     }
    3127
    3228    @Override
  • src/main/java/com/example/moviezone/service/ProjectionService.java

    r448bd84 reb5426c  
    99public interface ProjectionService {
    1010    List<Projection> findAllProjections();
    11 List<Projection> findAllAvailableProjections(LocalDate date);
    1211Projection save(LocalDate date_time_start,LocalDate date_time_end, String type_of_technology, Integer id_film );
    1312}
  • src/main/java/com/example/moviezone/web/HomeController.java

    r448bd84 reb5426c  
    33
    44import com.example.moviezone.model.Customer;
     5import com.example.moviezone.model.Film;
    56import com.example.moviezone.model.User;
    67import com.example.moviezone.model.exceptions.UserNotFoundException;
     
    910import org.springframework.stereotype.Controller;
    1011import org.springframework.ui.Model;
    11 import org.springframework.web.bind.annotation.GetMapping;
    12 import org.springframework.web.bind.annotation.PostMapping;
    13 import org.springframework.web.bind.annotation.RequestMapping;
    14 import org.springframework.web.bind.annotation.RequestParam;
     12import org.springframework.web.bind.annotation.*;
    1513
    1614import javax.servlet.http.HttpSession;
    1715import java.time.LocalDate;
     16import java.util.List;
     17import java.util.Optional;
     18import java.util.stream.Collectors;
    1819
    1920@Controller
    20 @RequestMapping("/")
     21@RequestMapping({"/","/home"})
    2122public class HomeController {
    2223
     
    3738    }
    3839
    39     @GetMapping({"/","/home"})
     40    @GetMapping
    4041    public String getHomePage(Model model) {
     42        List<Film> films=filmService.findAllFilms();
     43        films=films.stream().limit(5).collect(Collectors.toList());
     44        model.addAttribute("films", films);
    4145        model.addAttribute("bodyContent", "home");
     46
     47        return "master-template";
     48    }
     49    @GetMapping("/getFilm/{id}")
     50    public String getFilm(@PathVariable Long id, Model model) {
     51        Optional<Film> film=filmService.getFilmById(id);
     52        model.addAttribute("film", film);
     53        model.addAttribute("bodyContent", "home");
     54
    4255        return "master-template";
    4356    }
     
    97110    public String getProjectionsPage(Model model)
    98111    {
    99         model.addAttribute("projections",projectionService.findAllAvailableProjections(LocalDate.now()));
     112        model.addAttribute("projections",projectionService.findAllProjections());
    100113        model.addAttribute("bodyContent","projections");
    101114        return "master-template";
  • src/main/resources/templates/fragments/header.html

    r448bd84 reb5426c  
    5858</style>
    5959<body>
     60<div style="width: 100%">
    6061<nav class="menu">
    6162    <ul class="menu-left">
     
    7071        <li class="reg"><a href="#!">Регистрација</a></li>
    7172    </ul>
    72 </nav>
     73</nav></div>
    7374</body>
    7475</html>
  • src/main/resources/templates/master-template.html

    r448bd84 reb5426c  
    11<!DOCTYPE html>
    2 <html lang="en">
     2<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
    33<head>
    4     <meta charset="UTF-8">
    5     <title>Title</title>
     4    <meta charset="UTF-8"/>
     5    <title>MovieZone</title>
     6    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
     7    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
     8    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
     9    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    610</head>
    711<body>
     12<header th:replace="fragments/header"/>
    813
     14<section th:include="${bodyContent}">
     15
     16</section>
     17<!-- Footer -->
    918</body>
    1019</html>
Note: See TracChangeset for help on using the changeset viewer.