Changes in / [f8ef9bd:608fefef]
- Location:
- src/main
- Files:
-
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/config/WebSecurityConfig.java
rf8ef9bd r608fefef 32 32 http.csrf().disable() 33 33 .authorizeRequests() 34 .antMatchers("/", "/home/getFilm/**","/home", "/assets/**", "/register", "/api/**").permitAll()34 .antMatchers("/", "/home", "/assets/**", "/register", "/api/**").permitAll() 35 35 .antMatchers("/admin/**").hasRole("ADMIN") 36 36 .anyRequest() -
src/main/java/com/example/moviezone/model/Film.java
rf8ef9bd r608fefef 46 46 47 47 } 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 }88 48 } -
src/main/java/com/example/moviezone/model/Projection.java
rf8ef9bd r608fefef 39 39 this.film = film; 40 40 } 41 42 public Projection() {43 }44 41 } -
src/main/java/com/example/moviezone/repository/FilmRepository.java
rf8ef9bd r608fefef 3 3 import com.example.moviezone.model.Film; 4 4 import org.springframework.data.jpa.repository.JpaRepository; 5 import org.springframework.data.jpa.repository.query.Procedure;6 import org.springframework.data.repository.query.Param;7 8 import java.util.List;9 5 10 6 public interface FilmRepository extends JpaRepository<Film,Integer> { 11 12 7 } -
src/main/java/com/example/moviezone/repository/ProjectionRepository.java
rf8ef9bd r608fefef 9 9 public interface ProjectionRepository extends JpaRepository<Projection,Integer> { 10 10 // NOTE: CHANGE THIS WITH MATERIALIZED VIEW 11 //List<Projection> findAllBydate_time_startBefore(LocalDate datum);11 List<Projection> findAllByDate_time_startBefore(LocalDate datum); 12 12 } -
src/main/java/com/example/moviezone/service/FilmService.java
rf8ef9bd r608fefef 5 5 import java.time.LocalDate; 6 6 import java.util.List; 7 import java.util.Optional;8 7 9 8 public interface FilmService { … … 11 10 Film save(String name, Integer duration, String actors, String genre, 12 11 String age_category, String url, String director, LocalDate start_date,LocalDate end_date); 13 Optional<Film> getFilmById(Long id);14 12 } -
src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java
rf8ef9bd r608fefef 7 7 8 8 import java.time.LocalDate; 9 import java.util.Collections;10 9 import java.util.List; 11 import java.util.Optional;12 10 13 11 @Service … … 28 26 return filmRepository.save(new Film(name,duration,actors,genre,age_category,url,director,start_date,end_date)); 29 27 } 30 31 @Override32 public Optional<Film> getFilmById(Long id) {33 return filmRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();34 }35 36 28 } -
src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java
rf8ef9bd r608fefef 25 25 } 26 26 27 @Override 28 public List<Projection> findAllAvailableProjections(LocalDate date) { 29 return projectionRepository.findAllByDate_time_startBefore(date); 30 } 27 31 28 32 @Override -
src/main/java/com/example/moviezone/service/ProjectionService.java
rf8ef9bd r608fefef 9 9 public interface ProjectionService { 10 10 List<Projection> findAllProjections(); 11 List<Projection> findAllAvailableProjections(LocalDate date); 11 12 Projection save(LocalDate date_time_start,LocalDate date_time_end, String type_of_technology, Integer id_film ); 12 13 } -
src/main/java/com/example/moviezone/web/HomeController.java
rf8ef9bd r608fefef 3 3 4 4 import com.example.moviezone.model.Customer; 5 import com.example.moviezone.model.Film;6 5 import com.example.moviezone.model.User; 7 6 import com.example.moviezone.model.exceptions.UserNotFoundException; … … 10 9 import org.springframework.stereotype.Controller; 11 10 import org.springframework.ui.Model; 12 import org.springframework.web.bind.annotation.*; 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; 13 15 14 16 import javax.servlet.http.HttpSession; 15 17 import java.time.LocalDate; 16 import java.util.List;17 import java.util.Optional;18 import java.util.stream.Collectors;19 18 20 19 @Controller 21 @RequestMapping( {"/","/home"})20 @RequestMapping("/") 22 21 public class HomeController { 23 22 … … 38 37 } 39 38 40 @GetMapping 39 @GetMapping({"/","/home"}) 41 40 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);45 41 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 55 42 return "master-template"; 56 43 } … … 110 97 public String getProjectionsPage(Model model) 111 98 { 112 model.addAttribute("projections",projectionService.findAll Projections());99 model.addAttribute("projections",projectionService.findAllAvailableProjections(LocalDate.now())); 113 100 model.addAttribute("bodyContent","projections"); 114 101 return "master-template"; -
src/main/resources/templates/fragments/header.html
rf8ef9bd r608fefef 58 58 </style> 59 59 <body> 60 <div style="width: 100%">61 60 <nav class="menu"> 62 61 <ul class="menu-left"> … … 71 70 <li class="reg"><a href="#!">Регистрација</a></li> 72 71 </ul> 73 </nav> </div>72 </nav> 74 73 </body> 75 74 </html> -
src/main/resources/templates/master-template.html
rf8ef9bd r608fefef 3 3 <head> 4 4 <meta charset="UTF-8"/> 5 6 <title>MovieZone</title> 7 5 <title>Products</title> 8 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"> 9 7 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> … … 19 17 20 18 <footer th:replace="fragments/footer"/> 21 22 19 </body> 23 20 </html>
Note:
See TracChangeset
for help on using the changeset viewer.