Changeset bde8b13 for src/main/java/mk/ukim/finki/busngo/web
- Timestamp:
- 01/09/24 01:26:08 (11 months ago)
- Branches:
- master
- Children:
- e272096
- Parents:
- b101b69
- Location:
- src/main/java/mk/ukim/finki/busngo/web
- Files:
-
- 4 added
- 2 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 } -
src/main/java/mk/ukim/finki/busngo/web/RegisterController.java
rb101b69 rbde8b13 1 1 package mk.ukim.finki.busngo.web; 2 2 3 import mk.ukim.finki.busngo.model.en ums.Role;3 import mk.ukim.finki.busngo.model.entities.Korisnik; 4 4 import mk.ukim.finki.busngo.model.exceptions.InvalidCredentialsException; 5 5 import mk.ukim.finki.busngo.model.exceptions.UserAlreadyExistsException; 6 6 import mk.ukim.finki.busngo.service.AuthService; 7 7 import mk.ukim.finki.busngo.service.KorisnikService; 8 import mk.ukim.finki.busngo.service.PatnikService; 8 9 import org.springframework.stereotype.Controller; 9 10 import org.springframework.ui.Model; … … 18 19 private final AuthService authService; 19 20 private final KorisnikService korisnikService; 21 private final PatnikService patnikService; 20 22 21 public RegisterController(AuthService authService, KorisnikService korisnikService ) {23 public RegisterController(AuthService authService, KorisnikService korisnikService, PatnikService patnikService) { 22 24 this.authService = authService; 23 25 this.korisnikService = korisnikService; 26 this.patnikService = patnikService; 24 27 } 25 28 … … 44 47 ) { 45 48 try{ 46 this.authService.register(name, email, password, confirmPassword, address, phone); 49 Korisnik korisnik = this.authService.registerPatnik(name, email, password, confirmPassword, address, phone); 50 this.patnikService.save(korisnik); 47 51 return "redirect:/login"; 48 52 } catch (InvalidCredentialsException | UserAlreadyExistsException exception) { … … 51 55 } 52 56 57 // @PostMapping 58 // public String registerVraboten(@RequestParam String name, 59 // @RequestParam String email, 60 // @RequestParam String password, 61 // @RequestParam String confirmPassword, 62 // @RequestParam String address, 63 // @RequestParam String phone){ 64 // 65 // } 66 53 67 }
Note:
See TracChangeset
for help on using the changeset viewer.