Ignore:
Timestamp:
02/18/24 22:01:54 (9 months ago)
Author:
ppaunovski <paunovskipavel@…>
Branches:
master
Children:
4251327
Parents:
bde8b13
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:
5 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/mk/ukim/finki/busngo/web/BiletController.java

    rbde8b13 re272096  
    4141        Patnik patnik = null;
    4242        try{
     43            patnik = patnikService.loadUserByEmail(authentication.getName());
    4344            model.addAttribute("bileti", biletService.findAllByPatnikEmail(authentication.getName()));
    4445        }
  • src/main/java/mk/ukim/finki/busngo/web/InstancaNaLinijaController.java

    rbde8b13 re272096  
    7171
    7272    @PostMapping("/{inlId}/end")
    73     public String endInstanca(@PathVariable Long inlId){
    74         Instancanalinija ended = instancaNaLinijaService.end(inlId);
     73    public String endInstanca(@PathVariable Long inlId,
     74                              Authentication authentication){
     75        Instancanalinija ended = instancaNaLinijaService.end(inlId, authentication.getName());
    7576        return "redirect:/instanca-na-linija/" + ended.getInlId();
    7677    }
  • src/main/java/mk/ukim/finki/busngo/web/KaznaController.java

    rbde8b13 re272096  
    99import org.springframework.ui.Model;
    1010import org.springframework.web.bind.annotation.GetMapping;
     11import org.springframework.web.bind.annotation.PathVariable;
     12import org.springframework.web.bind.annotation.PostMapping;
    1113import org.springframework.web.bind.annotation.RequestMapping;
    1214
     
    3739        return "master-template";
    3840    }
     41
     42    @PostMapping("/{id}/pay")
     43    public String pay(@PathVariable Long id,
     44                      Model model){
     45        kaznaZaRegistriranService.pay(id);
     46        return "redirect:/kazna";
     47    }
     48
    3949}
  • src/main/java/mk/ukim/finki/busngo/web/RegisterController.java

    rbde8b13 re272096  
    22
    33import mk.ukim.finki.busngo.model.entities.Korisnik;
     4import mk.ukim.finki.busngo.model.enums.VrabotenType;
    45import mk.ukim.finki.busngo.model.exceptions.InvalidCredentialsException;
    56import mk.ukim.finki.busngo.model.exceptions.UserAlreadyExistsException;
     
    3435        }
    3536
     37        model.addAttribute("types", VrabotenType.values());
     38
    3639        model.addAttribute("bodyContent", "register");
    3740        return "master-template";
     
    4447                           @RequestParam String confirmPassword,
    4548                           @RequestParam String address,
    46                            @RequestParam String phone
    47     ) {
     49                           @RequestParam String phone,
     50                           @RequestParam(required = false)VrabotenType vrabotenType,
     51                           @RequestParam(required = false) Double salary
     52                           ) {
    4853        try{
    49             Korisnik korisnik = this.authService.registerPatnik(name, email, password, confirmPassword, address, phone);
    50             this.patnikService.save(korisnik);
     54            Korisnik korisnik;
     55            if(vrabotenType != null){
     56                 korisnik = this.authService.registerVraboten(name, email, password, confirmPassword, address, phone, vrabotenType, salary);
     57
     58            }
     59            else
     60                korisnik = this.authService.registerPatnik(name, email, password, confirmPassword, address, phone);
    5161            return "redirect:/login";
    5262        } catch (InvalidCredentialsException | UserAlreadyExistsException exception) {
  • src/main/java/mk/ukim/finki/busngo/web/VozenjeController.java

    rbde8b13 re272096  
    44import mk.ukim.finki.busngo.model.entities.Patnik;
    55import mk.ukim.finki.busngo.model.entities.Vozenje;
     6import mk.ukim.finki.busngo.model.enums.VOZENJE_STATUS;
    67import mk.ukim.finki.busngo.model.exceptions.InvalidPatnikIdException;
    78import mk.ukim.finki.busngo.model.exceptions.InvalidPostojkaNaLinijaIdException;
     
    2930    @GetMapping()
    3031    public String getVozenjePage(Model model,
    31                                  Authentication authentication){
     32                                 Authentication authentication,
     33                                 @RequestParam(required = false) VOZENJE_STATUS status){
    3234        model.addAttribute("bodyContent", "listVozenja");
    3335        Patnik patnik = null;
    3436        try{
    35             model.addAttribute("vozenja", vozenjeService.findVozenjaByPatnik(authentication.getName()));
     37            if(status != null)
     38                model.addAttribute("vozenja", vozenjeService.findVozenjaByPatnikAndStatus(authentication.getName(), status));
     39            else
     40                model.addAttribute("vozenja", vozenjeService.findVozenjaByPatnikAndStatus(authentication.getName(), VOZENJE_STATUS.ACTIVE));
     41            model.addAttribute("vozStatus", VOZENJE_STATUS.values());
    3642        }
    3743        catch (InvalidPatnikIdException e){
Note: See TracChangeset for help on using the changeset viewer.