fix: usuarios service, usuario controller/ para que reciba ci, nombre, celular.
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-03-05 15:56:28 -04:00
parent f3e99fa830
commit 38e573e5fc
4 changed files with 95 additions and 12 deletions

View File

@@ -26,16 +26,16 @@ public class AppController {
} }
// Registro // Registro
@PostMapping("/auth/registrar") // @PostMapping("/auth/registrar")
public ResponseEntity<String> registrar(@RequestParam String username, // public ResponseEntity<String> registrar(@RequestParam String username,
@RequestParam String password) { // @RequestParam String password) {
if (usuarioService.estaRegistrado(username)) { // if (usuarioService.estaRegistrado(username)) {
return ResponseEntity.status(HttpStatus.CONFLICT).body("Usuario ya existe ❌"); // return ResponseEntity.status(HttpStatus.CONFLICT).body("Usuario ya existe ❌");
} // }
//
usuarioService.registrarUsuario(username, password, Set.of(Rol.CLIENTE), 1L); // usuarioService.registrarUsuario(username, password, Set.of(Rol.CLIENTE), 1L);
return ResponseEntity.ok("Usuario registrado, pendiente de aprobación ✅"); // return ResponseEntity.ok("Usuario registrado, pendiente de aprobación ✅");
} // }

View File

@@ -34,7 +34,14 @@ public class UserController {
// ✅ Registrar nuevo usuario // ✅ Registrar nuevo usuario
@PostMapping("/registrar") @PostMapping("/registrar")
public Usuario registrarUsuario(@RequestBody UsuarioRequest request) { public Usuario registrarUsuario(@RequestBody UsuarioRequest request) {
return service.registrarUsuario(request.getUsername(), request.getPassword(), request.getRoles(), request.getRol() ); return service.registrarUsuario(
request.getUsername(),
request.getPassword(),
request.getRoles(),
request.getRol(),
request.getCi(),
request.getCelular(),
request.getNombre());
} }
// ✅ Listar usuarios pendientes (no aprobados) // ✅ Listar usuarios pendientes (no aprobados)
@@ -112,6 +119,41 @@ public class UserController {
private String password; private String password;
private Set<Rol> roles; //ignora esto private Set<Rol> roles; //ignora esto
private Long rolId; private Long rolId;
private Long ci;
private Long celular;
private String nombre;
public Long getRolId() {
return rolId;
}
public void setRolId(Long rolId) {
this.rolId = rolId;
}
public Long getCi() {
return ci;
}
public void setCi(Long ci) {
this.ci = ci;
}
public Long getCelular() {
return celular;
}
public void setCelular(Long celular) {
this.celular = celular;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public Long getRol() { public Long getRol() {
return rolId; return rolId;

View File

@@ -23,11 +23,49 @@ public class Usuario {
@JoinColumn(name = "RolId") @JoinColumn(name = "RolId")
private Roles rol; private Roles rol;
private Long ci;
private Long celular;
private String nombre;
private Boolean visible = true; private Boolean visible = true;
// getters y setters // getters y setters
public Boolean getAprobado() {
return aprobado;
}
public void setAprobado(Boolean aprobado) {
this.aprobado = aprobado;
}
public Long getCi() {
return ci;
}
public void setCi(Long ci) {
this.ci = ci;
}
public Long getCelular() {
return celular;
}
public void setCelular(Long celular) {
this.celular = celular;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public Roles getRol() { public Roles getRol() {
return rol; return rol;
} }

View File

@@ -26,7 +26,7 @@ public class UsuarioService {
this.rolesRepository = rolesRepository; this.rolesRepository = rolesRepository;
} }
public Usuario registrarUsuario(String username, String password, Set<Rol> roles, Long rolId) { public Usuario registrarUsuario(String username, String password, Set<Rol> roles, Long rolId, Long ci, Long celular, String nombre) {
Roles rol = rolesRepository.findById(rolId) Roles rol = rolesRepository.findById(rolId)
.orElseThrow(() -> new RuntimeException("Rol no encontrado")); .orElseThrow(() -> new RuntimeException("Rol no encontrado"));
Usuario u = new Usuario(); Usuario u = new Usuario();
@@ -35,6 +35,9 @@ public class UsuarioService {
u.setRoles(roles); u.setRoles(roles);
u.setRol(rol); u.setRol(rol);
u.setAprobado(false); // no aprobado hasta aceptación u.setAprobado(false); // no aprobado hasta aceptación
u.setCi(ci);
u.setCelular(celular);
u.setNombre(nombre);
return repo.save(u); return repo.save(u);
} }