Changeset eb5426c for src/main/java/com


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

Home Page

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  
    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";
Note: See TracChangeset for help on using the changeset viewer.