2025-03-24 18:55:09 +00:00
|
|
|
package com.ieslamar.GestionInventario.controllers;
|
|
|
|
|
|
|
|
|
|
|
2025-03-26 14:54:51 +00:00
|
|
|
import com.ieslamar.GestionInventario.services.UserService;
|
2025-03-24 18:55:09 +00:00
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
|
public class UserController {
|
|
|
|
|
|
|
|
|
|
private final UserService userService;
|
|
|
|
|
|
|
|
|
|
public UserController(UserService userService) {
|
|
|
|
|
this.userService = userService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/login")
|
|
|
|
|
public String loginPage() {
|
|
|
|
|
return "login"; // Retorna la vista login.html
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/home")
|
|
|
|
|
public String homePage(Model model) {
|
|
|
|
|
model.addAttribute("message", "Bienvenido a Gestión de Inventario");
|
|
|
|
|
return "home"; // Retorna la vista home.html
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/register")
|
|
|
|
|
public String registerPage() {
|
|
|
|
|
return "register"; // Retorna la vista register.html
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/register")
|
2025-03-27 18:51:14 +00:00
|
|
|
public String register(@RequestParam String username, @RequestParam String password, @RequestParam String role, @RequestParam String mail) {
|
|
|
|
|
userService.registerUser(username, password, role, mail);
|
2025-03-24 18:55:09 +00:00
|
|
|
return "redirect:/login?success"; // Redirige al login tras registrarse
|
|
|
|
|
}
|
2025-03-28 15:16:00 +00:00
|
|
|
@GetMapping("/management")
|
|
|
|
|
public String managementPage(){
|
|
|
|
|
return "management";
|
|
|
|
|
}
|
|
|
|
|
@GetMapping("/user_managemment")
|
|
|
|
|
public String userManagementPage(){
|
|
|
|
|
return "user_management";
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-24 18:55:09 +00:00
|
|
|
}
|