package com.project.beautycenter.web; import com.project.beautycenter.model.Klienti; import com.project.beautycenter.service.KlientiService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @Controller public class KlientiController { private final KlientiService klientiService; public KlientiController(KlientiService klientiService) { this.klientiService = klientiService; } @GetMapping("/clients") public String showClients(Model model) { List klienti = this.klientiService.listAll(); model.addAttribute("klienti", klienti); return "clients.html"; } @GetMapping("/clients/{id}/edit") public String showEdit(@PathVariable Integer id, Model model) { Klienti klient = this.klientiService.findById(id); model.addAttribute("klient", klient); return "edit_form.html"; } @PostMapping("/clients/{id}") public String update(@PathVariable Integer id, @RequestParam String ime, @RequestParam String prezime, @RequestParam String telBr, @RequestParam String email) { this.klientiService.update(id, ime, prezime, telBr, email); return "redirect:/clients"; } }