Changeset eb5426c for src/main/java/com/example
- Timestamp:
- 02/06/23 03:59:41 (23 months ago)
- Branches:
- master
- Children:
- f8ef9bd
- Parents:
- 448bd84
- Location:
- src/main/java/com/example/moviezone
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/config/WebSecurityConfig.java
r448bd84 reb5426c 32 32 http.csrf().disable() 33 33 .authorizeRequests() 34 .antMatchers("/", "/home", "/assets/**", "/register", "/api/**").permitAll()34 .antMatchers("/","/home/getFilm/**", "/home", "/assets/**", "/register", "/api/**").permitAll() 35 35 .antMatchers("/admin/**").hasRole("ADMIN") 36 36 .anyRequest() -
src/main/java/com/example/moviezone/model/Film.java
r448bd84 reb5426c 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 } 48 88 } -
src/main/java/com/example/moviezone/model/Projection.java
r448bd84 reb5426c 39 39 this.film = film; 40 40 } 41 42 public Projection() { 43 } 41 44 } -
src/main/java/com/example/moviezone/repository/FilmRepository.java
r448bd84 reb5426c 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; 5 9 6 10 public interface FilmRepository extends JpaRepository<Film,Integer> { 11 7 12 } -
src/main/java/com/example/moviezone/repository/ProjectionRepository.java
r448bd84 reb5426c 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
r448bd84 reb5426c 5 5 import java.time.LocalDate; 6 6 import java.util.List; 7 import java.util.Optional; 7 8 8 9 public interface FilmService { … … 10 11 Film save(String name, Integer duration, String actors, String genre, 11 12 String age_category, String url, String director, LocalDate start_date,LocalDate end_date); 13 Optional<Film> getFilmById(Long id); 12 14 } -
src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java
r448bd84 reb5426c 7 7 8 8 import java.time.LocalDate; 9 import java.util.Collections; 9 10 import java.util.List; 11 import java.util.Optional; 10 12 11 13 @Service … … 26 28 return filmRepository.save(new Film(name,duration,actors,genre,age_category,url,director,start_date,end_date)); 27 29 } 30 31 @Override 32 public Optional<Film> getFilmById(Long id) { 33 return filmRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst(); 34 } 35 28 36 } -
src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java
r448bd84 reb5426c 25 25 } 26 26 27 @Override28 public List<Projection> findAllAvailableProjections(LocalDate date) {29 return projectionRepository.findAllByDate_time_startBefore(date);30 }31 27 32 28 @Override -
src/main/java/com/example/moviezone/service/ProjectionService.java
r448bd84 reb5426c 9 9 public interface ProjectionService { 10 10 List<Projection> findAllProjections(); 11 List<Projection> findAllAvailableProjections(LocalDate date);12 11 Projection save(LocalDate date_time_start,LocalDate date_time_end, String type_of_technology, Integer id_film ); 13 12 } -
src/main/java/com/example/moviezone/web/HomeController.java
r448bd84 reb5426c 3 3 4 4 import com.example.moviezone.model.Customer; 5 import com.example.moviezone.model.Film; 5 6 import com.example.moviezone.model.User; 6 7 import com.example.moviezone.model.exceptions.UserNotFoundException; … … 9 10 import org.springframework.stereotype.Controller; 10 11 import 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; 12 import org.springframework.web.bind.annotation.*; 15 13 16 14 import javax.servlet.http.HttpSession; 17 15 import java.time.LocalDate; 16 import java.util.List; 17 import java.util.Optional; 18 import java.util.stream.Collectors; 18 19 19 20 @Controller 20 @RequestMapping( "/")21 @RequestMapping({"/","/home"}) 21 22 public class HomeController { 22 23 … … 37 38 } 38 39 39 @GetMapping ({"/","/home"})40 @GetMapping 40 41 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); 41 45 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 42 55 return "master-template"; 43 56 } … … 97 110 public String getProjectionsPage(Model model) 98 111 { 99 model.addAttribute("projections",projectionService.findAll AvailableProjections(LocalDate.now()));112 model.addAttribute("projections",projectionService.findAllProjections()); 100 113 model.addAttribute("bodyContent","projections"); 101 114 return "master-template";
Note:
See TracChangeset
for help on using the changeset viewer.