1 | package com.example.demo.controller;
|
---|
2 |
|
---|
3 | import com.example.demo.model.Client.Client;
|
---|
4 | import com.example.demo.model.Genre;
|
---|
5 | import com.example.demo.repository.ClientRepository;
|
---|
6 | import com.example.demo.repository.FirmRepository;
|
---|
7 | import com.example.demo.repository.GenreRepository;
|
---|
8 | import com.example.demo.repository.ReservationsRepository;
|
---|
9 | import org.springframework.stereotype.Controller;
|
---|
10 | import org.springframework.ui.Model;
|
---|
11 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
12 | import org.springframework.web.bind.annotation.RequestMapping;
|
---|
13 | import org.springframework.web.bind.annotation.RequestParam;
|
---|
14 |
|
---|
15 | import java.util.Collection;
|
---|
16 | import java.util.List;
|
---|
17 |
|
---|
18 | @Controller
|
---|
19 | @RequestMapping("/employee")
|
---|
20 | public class EmployeeController {
|
---|
21 |
|
---|
22 | private final ReservationsRepository reservationsRepository;
|
---|
23 | private final FirmRepository firmRepository;
|
---|
24 | private final ClientRepository clientRepository;
|
---|
25 | private final GenreRepository genreRepository;
|
---|
26 |
|
---|
27 | public EmployeeController(ReservationsRepository reservationsRepository, FirmRepository firmRepository, ClientRepository clientRepository, GenreRepository genreRepository) {
|
---|
28 | this.reservationsRepository = reservationsRepository;
|
---|
29 | this.firmRepository = firmRepository;
|
---|
30 | this.clientRepository = clientRepository;
|
---|
31 | this.genreRepository = genreRepository;
|
---|
32 | }
|
---|
33 |
|
---|
34 | @GetMapping
|
---|
35 | public String getMoviePage(@RequestParam(required = false) String error, Model model) {
|
---|
36 | if (error != null && !error.isEmpty()) {
|
---|
37 | model.addAttribute("hasError", true);
|
---|
38 | model.addAttribute("error", error);
|
---|
39 | }
|
---|
40 | Collection<Client> clients = this.clientRepository.findByUsersStats();
|
---|
41 | model.addAttribute("clients", clients);
|
---|
42 | return "employee";
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | }
|
---|