1 | package com.example.demo.controller;
|
---|
2 |
|
---|
3 | import com.example.demo.model.Auditorium;
|
---|
4 | import com.example.demo.model.Movie;
|
---|
5 | import com.example.demo.repository.AuditoriumRepository;
|
---|
6 | import org.springframework.stereotype.Controller;
|
---|
7 | import org.springframework.ui.Model;
|
---|
8 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
9 | import org.springframework.web.bind.annotation.RequestMapping;
|
---|
10 | import org.springframework.web.bind.annotation.RequestParam;
|
---|
11 |
|
---|
12 | import java.util.List;
|
---|
13 |
|
---|
14 | @Controller
|
---|
15 | @RequestMapping("/auditoriums")
|
---|
16 | public class AuditoriumController {
|
---|
17 |
|
---|
18 | private final AuditoriumRepository auditoriumRepository;
|
---|
19 |
|
---|
20 |
|
---|
21 | public AuditoriumController(AuditoriumRepository auditoriumRepository) {
|
---|
22 | this.auditoriumRepository = auditoriumRepository;
|
---|
23 | }
|
---|
24 |
|
---|
25 | @GetMapping
|
---|
26 | public String getProductPage(@RequestParam(required = false) String error, Model model) {
|
---|
27 | if (error != null && !error.isEmpty()) {
|
---|
28 | model.addAttribute("hasError", true);
|
---|
29 | model.addAttribute("error", error);
|
---|
30 | }
|
---|
31 | List<Auditorium> auditoriums = this.auditoriumRepository.findAll();
|
---|
32 | model.addAttribute("auditorium", auditoriums);
|
---|
33 | model.addAttribute("bodyContent", "auditoriums");
|
---|
34 | return "master-template";
|
---|
35 | }
|
---|
36 | }
|
---|