1 | package mk.ukim.finki.busngo.web;
|
---|
2 |
|
---|
3 | import mk.ukim.finki.busngo.model.entities.Patnik;
|
---|
4 | import mk.ukim.finki.busngo.model.exceptions.InvalidPatnikIdException;
|
---|
5 | import mk.ukim.finki.busngo.service.KaznaZaRegistriranService;
|
---|
6 | import mk.ukim.finki.busngo.service.VozenjeService;
|
---|
7 | import org.springframework.security.core.Authentication;
|
---|
8 | import org.springframework.stereotype.Controller;
|
---|
9 | import org.springframework.ui.Model;
|
---|
10 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
11 | import org.springframework.web.bind.annotation.RequestMapping;
|
---|
12 |
|
---|
13 | @Controller
|
---|
14 | @RequestMapping("/kazna")
|
---|
15 | public class KaznaController {
|
---|
16 | private final KaznaZaRegistriranService kaznaZaRegistriranService;
|
---|
17 |
|
---|
18 | public KaznaController(KaznaZaRegistriranService kaznaZaRegistriranService) {
|
---|
19 | this.kaznaZaRegistriranService = kaznaZaRegistriranService;
|
---|
20 | }
|
---|
21 |
|
---|
22 | @GetMapping()
|
---|
23 | public String getKaznaPage(Model model,
|
---|
24 | Authentication authentication){
|
---|
25 | model.addAttribute("bodyContent", "listKazni");
|
---|
26 | Patnik patnik = null;
|
---|
27 | try{
|
---|
28 | model.addAttribute("kazni", kaznaZaRegistriranService.findAllByPatnik(authentication.getName()));
|
---|
29 | }
|
---|
30 | catch (InvalidPatnikIdException e){
|
---|
31 | model.addAttribute("bodyContent", "listBileti");
|
---|
32 | model.addAttribute("hasError", true);
|
---|
33 | model.addAttribute("error", e.getMessage());
|
---|
34 | return "master-template";
|
---|
35 | }
|
---|
36 |
|
---|
37 | return "master-template";
|
---|
38 | }
|
---|
39 | }
|
---|