- Timestamp:
- 01/09/24 01:26:08 (10 months ago)
- Branches:
- master
- Children:
- e272096
- Parents:
- b101b69
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/mk/ukim/finki/busngo/web/BiletController.java
rb101b69 rbde8b13 1 1 package mk.ukim.finki.busngo.web; 2 2 3 import mk.ukim.finki.busngo.model.entities.Patnik; 3 4 import mk.ukim.finki.busngo.model.enums.BILET_STATUS; 5 import mk.ukim.finki.busngo.model.exceptions.InvalidPatnikIdException; 4 6 import mk.ukim.finki.busngo.service.AuthService; 5 7 import mk.ukim.finki.busngo.service.BiletService; 8 import mk.ukim.finki.busngo.service.PatnikService; 6 9 import mk.ukim.finki.busngo.service.TipBiletService; 7 10 import org.springframework.security.core.Authentication; … … 21 24 private final TipBiletService tipBiletService; 22 25 private final AuthService authService; 26 private final PatnikService patnikService; 23 27 24 public BiletController(BiletService biletService, TipBiletService tipBiletService, AuthService authService ) {28 public BiletController(BiletService biletService, TipBiletService tipBiletService, AuthService authService, PatnikService patnikService) { 25 29 this.biletService = biletService; 26 30 this.tipBiletService = tipBiletService; 27 31 this.authService = authService; 32 this.patnikService = patnikService; 28 33 } 29 34 … … 31 36 public String getAllBileti(@RequestParam(required = false) Long id, 32 37 @RequestParam(required = false) BILET_STATUS status, 33 Model model){ 38 Model model, 39 Authentication authentication){ 34 40 model.addAttribute("bodyContent", "listBileti"); 35 model.addAttribute("bileti", biletService.listAll()); 41 Patnik patnik = null; 42 try{ 43 model.addAttribute("bileti", biletService.findAllByPatnikEmail(authentication.getName())); 44 } 45 catch (InvalidPatnikIdException e){ 46 model.addAttribute("bodyContent", "listBileti"); 47 model.addAttribute("hasError", true); 48 model.addAttribute("error", e.getMessage()); 49 return "master-template"; 50 } 51 36 52 return "master-template"; 37 53 } … … 50 66 } 51 67 68 // @GetMapping("/encode") 69 // public String encode(){ 70 // biletService.encode(); 71 // return "redirect:/bilet"; 72 // } 73 52 74 }
Note:
See TracChangeset
for help on using the changeset viewer.