Commit 66ef61fe by Rubén Ramírez

feat: [ServicioController]: Añadida una función para buscar por nombre

parent 3428a5bf
......@@ -199,4 +199,18 @@ public class UsuariosController {
}
}
@GetMapping
public ResponseEntity<List<DTOUsuario>> filtrarUsuarios(@RequestParam(required = false) String nombre) {
try {
if (nombre == null || nombre.trim().isEmpty()) return ResponseEntity.badRequest().build();
List<Usuario> encontrados = servicioUsuarios.buscarPorNombre(nombre);
List<DTOUsuario> dto = encontrados.stream().map(mapper::dto).toList();
return dto.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(dto);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment