source: src/main/java/com/example/baziproekt/web/KorisniciController.java@ 0e4d807

Last change on this file since 0e4d807 was 0e4d807, checked in by Ivona <ivonatapshanovska@…>, 10 months ago

Initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1package com.example.baziproekt.web;
2
3
4import com.example.baziproekt.model.Korisnici;
5import com.example.baziproekt.model.Roles;
6import com.example.baziproekt.service.KorisniciService;
7import org.springframework.stereotype.Controller;
8import org.springframework.ui.Model;
9import org.springframework.web.bind.annotation.*;
10
11import java.util.List;
12
13@Controller
14@RequestMapping("/korisnici")
15public class KorisniciController {
16 private final KorisniciService service;
17
18 public KorisniciController(KorisniciService service) {
19 this.service = service;
20 }
21 @GetMapping
22 public String getKorisnici( Model model)
23 {
24 List<Korisnici> korisnicis=service.findAll();
25 model.addAttribute("korisnici",korisnicis);
26 return "korisnici";
27 }
28
29 @GetMapping("/{ime}/edit")
30 public String showEdit(@PathVariable String ime,Model model)
31 {
32 Korisnici k=service.findByIme(ime);
33 model.addAttribute("korisnik",k);
34 model.addAttribute("ulogi",Roles.values());
35
36 return "edit_form";
37
38 }
39 @PostMapping("/{korisnicko_ime}")
40 public String update(@PathVariable String korisnicko_ime, @RequestParam String lozinka,
41 @RequestParam String email,@RequestParam String telefonski_broj)
42 {
43
44 service.update(korisnicko_ime,lozinka,email,telefonski_broj);
45 return "redirect:/korisnici";
46 }
47
48
49
50}
Note: See TracBrowser for help on using the repository browser.