buscar usuario por id
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:
@@ -78,6 +78,12 @@ public class UserController {
|
||||
return ResponseEntity.ok("Usuario eliminado correctamente");
|
||||
}
|
||||
|
||||
@GetMapping("/id/{username}")
|
||||
public ResponseEntity<Long> getIdPorUsername(@PathVariable String username) {
|
||||
Long id = service.findId(username);
|
||||
return ResponseEntity.ok(id);
|
||||
}
|
||||
|
||||
|
||||
// ✅ DTO interno para registro
|
||||
public static class UsuarioRequest {
|
||||
|
||||
@@ -74,5 +74,14 @@ public class UsuarioService {
|
||||
repo.deleteById(id);
|
||||
}
|
||||
|
||||
//encontrar el usuario por gmail
|
||||
public Long findId(String username){
|
||||
Usuario usuario = repo.findByUsername(username)
|
||||
.orElseThrow(() -> new RuntimeException("Usuario no encontrado: " + username));
|
||||
|
||||
return usuario.getId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user