Changeset 5867520 for src/main/java/com


Ignore:
Timestamp:
02/08/23 15:48:51 (23 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
2c7a732
Parents:
90317ea
Message:

Projections

Location:
src/main/java/com/example/moviezone
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/model/manytomany/ProjectionIsPlayedInRoom.java

    r90317ea r5867520  
    2424    @Id
    2525    @Column(name ="id_projection")
    26     Integer id_projection;
     26    Integer idprojection;
    2727
    2828    @Id
    2929    @Column(name ="id_room")
    30     Integer id_room;
     30    Integer idroom;
    3131
    3232
  • src/main/java/com/example/moviezone/model/manytomany/ProjectionIsPlayedInRoomId.java

    r90317ea r5867520  
    77@Data
    88public class ProjectionIsPlayedInRoomId implements Serializable {
    9     Integer id_projection;
    10     Integer id_room;
     9    Integer idprojection;
     10    Integer idroom;
    1111}
  • src/main/java/com/example/moviezone/repository/ProjectionIsPlayedInRoomRepository.java

    r90317ea r5867520  
    1010
    1111public interface ProjectionIsPlayedInRoomRepository extends JpaRepository<ProjectionIsPlayedInRoom, ProjectionIsPlayedInRoomId> {
    12     @Query("SELECT pir FROM ProjectionIsPlayedInRoom pir WHERE pir.id_projection = :id_projection")
     12    @Query("SELECT pir FROM ProjectionIsPlayedInRoom pir WHERE pir.idprojection = :id_projection")
    1313    List<ProjectionIsPlayedInRoom> findAllByProjectionId(@Param("id_projection") Integer id_projection);
    1414}
  • src/main/java/com/example/moviezone/repository/ProjectionRepository.java

    r90317ea r5867520  
    33import com.example.moviezone.model.Projection;
    44import org.springframework.data.jpa.repository.JpaRepository;
     5import org.springframework.data.jpa.repository.query.Procedure;
    56
     7import javax.transaction.Transactional;
    68import java.time.LocalDate;
    79import java.util.List;
    8 
     10@Transactional
    911public interface ProjectionRepository extends JpaRepository<Projection,Integer> {
    10     //    NOTE: CHANGE THIS WITH MATERIALIZED VIEW
    11     //List<Projection> findAllBydate_time_startBefore(LocalDate datum);
     12    @Procedure("project.getProjectionsForFilms")
     13    List<Projection> getProjectionsForFilms(int id);
    1214}
  • src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java

    r90317ea r5867520  
    2626
    2727    @Override
     28    public List<Projection> getProjectionsForFilms(int id) {
     29        return projectionRepository.getProjectionsForFilms(id);
     30    }
     31
     32    @Override
    2833    public Projection findById(Integer id_projection) {
    2934        return projectionRepository.findById(id_projection).orElseThrow(RuntimeException::new);
  • src/main/java/com/example/moviezone/service/ProjectionService.java

    r90317ea r5867520  
    99public interface ProjectionService {
    1010    List<Projection> findAllProjections();
     11    List<Projection> getProjectionsForFilms(int id);
    1112    Projection findById(Integer id_projection);
    1213Projection save(LocalDate date_time_start,LocalDate date_time_end, String type_of_technology, Integer id_film );
  • src/main/java/com/example/moviezone/web/HomeController.java

    r90317ea r5867520  
    8585        model.addAttribute("event", event);
    8686        model.addAttribute("bodyContent", "event");
     87
     88        return "master-template";
     89    }
     90    @GetMapping("/getProjections/{id}")
     91    @Transactional
     92    public String getProjectionsFromFilm(@PathVariable Long id, Model model) {
     93        Film film=filmService.getFilmById(id).get();
     94        model.addAttribute("film",film);
     95        model.addAttribute("projections",projectionService.getProjectionsForFilms(id.intValue()));
     96        model.addAttribute("bodyContent", "projectionsForFilm");
    8797
    8898        return "master-template";
     
    168178            model.addAttribute("films",filmService.getFilmsNow());
    169179        }
    170         model.addAttribute("bodyContent","films");
     180        model.addAttribute("bodyContent","projections");
    171181        return "master-template";
    172182    }
Note: See TracChangeset for help on using the changeset viewer.