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
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -26,16 +26,16 @@ public class AppController {
|
||||
}
|
||||
|
||||
// Registro
|
||||
@PostMapping("/auth/registrar")
|
||||
public ResponseEntity<String> registrar(@RequestParam String username,
|
||||
@RequestParam String password) {
|
||||
if (usuarioService.estaRegistrado(username)) {
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).body("Usuario ya existe ❌");
|
||||
}
|
||||
|
||||
usuarioService.registrarUsuario(username, password, Set.of(Rol.CLIENTE), 1L);
|
||||
return ResponseEntity.ok("Usuario registrado, pendiente de aprobación ✅");
|
||||
}
|
||||
// @PostMapping("/auth/registrar")
|
||||
// public ResponseEntity<String> registrar(@RequestParam String username,
|
||||
// @RequestParam String password) {
|
||||
// if (usuarioService.estaRegistrado(username)) {
|
||||
// return ResponseEntity.status(HttpStatus.CONFLICT).body("Usuario ya existe ❌");
|
||||
// }
|
||||
//
|
||||
// usuarioService.registrarUsuario(username, password, Set.of(Rol.CLIENTE), 1L);
|
||||
// return ResponseEntity.ok("Usuario registrado, pendiente de aprobación ✅");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,14 @@ public class UserController {
|
||||
// ✅ Registrar nuevo usuario
|
||||
@PostMapping("/registrar")
|
||||
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)
|
||||
@@ -112,6 +119,41 @@ public class UserController {
|
||||
private String password;
|
||||
private Set<Rol> roles; //ignora esto
|
||||
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() {
|
||||
return rolId;
|
||||
|
||||
@@ -23,11 +23,49 @@ public class Usuario {
|
||||
@JoinColumn(name = "RolId")
|
||||
private Roles rol;
|
||||
|
||||
private Long ci;
|
||||
|
||||
private Long celular;
|
||||
|
||||
private String nombre;
|
||||
|
||||
private Boolean visible = true;
|
||||
|
||||
// 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() {
|
||||
return rol;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class UsuarioService {
|
||||
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)
|
||||
.orElseThrow(() -> new RuntimeException("Rol no encontrado"));
|
||||
Usuario u = new Usuario();
|
||||
@@ -35,6 +35,9 @@ public class UsuarioService {
|
||||
u.setRoles(roles);
|
||||
u.setRol(rol);
|
||||
u.setAprobado(false); // no aprobado hasta aceptación
|
||||
u.setCi(ci);
|
||||
u.setCelular(celular);
|
||||
u.setNombre(nombre);
|
||||
return repo.save(u);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user