|
@ -1,6 +1,5 @@ |
|
|
package es.fp.edu.conecta2.controladores; |
|
|
package es.fp.edu.conecta2.controladores; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import es.fp.edu.conecta2.modelo.user.User; |
|
|
import es.fp.edu.conecta2.modelo.user.User; |
|
|
import es.fp.edu.conecta2.servicios.UserService; |
|
|
import es.fp.edu.conecta2.servicios.UserService; |
|
|
import io.micrometer.common.util.StringUtils; |
|
|
import io.micrometer.common.util.StringUtils; |
|
@ -9,11 +8,9 @@ import org.springframework.stereotype.Controller; |
|
|
import org.springframework.ui.Model; |
|
|
import org.springframework.ui.Model; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
@Controller |
|
|
public class WebControlador { |
|
|
public class WebControlador { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private UserService servicioUser; |
|
|
private UserService servicioUser; |
|
|
@GetMapping ("/") |
|
|
@GetMapping ("/") |
|
@ -45,16 +42,16 @@ public class WebControlador { |
|
|
@PostMapping ("/actualizar") |
|
|
@PostMapping ("/actualizar") |
|
|
public String actualizaUser(@ModelAttribute("user") User usuario){ |
|
|
public String actualizaUser(@ModelAttribute("user") User usuario){ |
|
|
|
|
|
|
|
|
servicioUser.guardarId(usuario); |
|
|
|
|
|
|
|
|
servicioUser.actualizaId(usuario); |
|
|
|
|
|
|
|
|
return "redirect:/"; |
|
|
return "redirect:/"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping ("/borrar") |
|
|
|
|
|
|
|
|
@GetMapping ("/borrar/{num}") |
|
|
public String borrarUser(Model modelo){ |
|
|
public String borrarUser(Model modelo){ |
|
|
modelo.addAttribute("user",servicioUser.listarUser()); |
|
|
|
|
|
return "usuarios"; |
|
|
|
|
|
|
|
|
/{num} |
|
|
|
|
|
return "redirect:/"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|