Ignore:
Timestamp:
01/09/24 01:26:08 (11 months ago)
Author:
ppaunovski <paunovskipavel@…>
Branches:
master
Children:
e272096
Parents:
b101b69
Message:

All 3 main use cases implemented.

  1. Starting a commute
  2. Writing a ticket
  3. Starting an instance of a Bus Line
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  
    11package mk.ukim.finki.busngo.web;
    22
     3import mk.ukim.finki.busngo.model.entities.Patnik;
    34import mk.ukim.finki.busngo.model.enums.BILET_STATUS;
     5import mk.ukim.finki.busngo.model.exceptions.InvalidPatnikIdException;
    46import mk.ukim.finki.busngo.service.AuthService;
    57import mk.ukim.finki.busngo.service.BiletService;
     8import mk.ukim.finki.busngo.service.PatnikService;
    69import mk.ukim.finki.busngo.service.TipBiletService;
    710import org.springframework.security.core.Authentication;
     
    2124    private final TipBiletService tipBiletService;
    2225    private final AuthService authService;
     26    private final PatnikService patnikService;
    2327
    24     public BiletController(BiletService biletService, TipBiletService tipBiletService, AuthService authService) {
     28    public BiletController(BiletService biletService, TipBiletService tipBiletService, AuthService authService, PatnikService patnikService) {
    2529        this.biletService = biletService;
    2630        this.tipBiletService = tipBiletService;
    2731        this.authService = authService;
     32        this.patnikService = patnikService;
    2833    }
    2934
     
    3136    public String getAllBileti(@RequestParam(required = false) Long id,
    3237                               @RequestParam(required = false) BILET_STATUS status,
    33                                Model model){
     38                               Model model,
     39                               Authentication authentication){
    3440        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
    3652        return "master-template";
    3753    }
     
    5066    }
    5167
     68//    @GetMapping("/encode")
     69//    public String encode(){
     70//        biletService.encode();
     71//        return "redirect:/bilet";
     72//    }
     73
    5274}
  • src/main/java/mk/ukim/finki/busngo/web/RegisterController.java

    rb101b69 rbde8b13  
    11package mk.ukim.finki.busngo.web;
    22
    3 import mk.ukim.finki.busngo.model.enums.Role;
     3import mk.ukim.finki.busngo.model.entities.Korisnik;
    44import mk.ukim.finki.busngo.model.exceptions.InvalidCredentialsException;
    55import mk.ukim.finki.busngo.model.exceptions.UserAlreadyExistsException;
    66import mk.ukim.finki.busngo.service.AuthService;
    77import mk.ukim.finki.busngo.service.KorisnikService;
     8import mk.ukim.finki.busngo.service.PatnikService;
    89import org.springframework.stereotype.Controller;
    910import org.springframework.ui.Model;
     
    1819    private final AuthService authService;
    1920    private final KorisnikService korisnikService;
     21    private final PatnikService patnikService;
    2022
    21     public RegisterController(AuthService authService, KorisnikService korisnikService) {
     23    public RegisterController(AuthService authService, KorisnikService korisnikService, PatnikService patnikService) {
    2224        this.authService = authService;
    2325        this.korisnikService = korisnikService;
     26        this.patnikService = patnikService;
    2427    }
    2528
     
    4447    ) {
    4548        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);
    4751            return "redirect:/login";
    4852        } catch (InvalidCredentialsException | UserAlreadyExistsException exception) {
     
    5155    }
    5256
     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
    5367}
Note: See TracChangeset for help on using the changeset viewer.