Exemplo n.º 1
0
 /**
  * Write a page of event tweet search results to the body of the response. The page number and
  * size may be provided by the client. If not specified, defaults to the first page of ten
  * results.
  */
 @RequestMapping(
     value = "/events/{eventId}/tweets",
     method = RequestMethod.GET,
     produces = "application/json")
 public @ResponseBody SearchResults tweets(
     @PathVariable Long eventId,
     @RequestParam(defaultValue = "1") Integer page,
     @RequestParam(defaultValue = "10") Integer pageSize) {
   String searchString = eventRepository.findEventSearchString(eventId);
   return searchString != null && searchString.length() > 0
       ? twitter.searchOperations().search(searchString, page, pageSize)
       : null;
 }
 @RequestMapping("/result")
 public String hello(@RequestParam(defaultValue = "slawomir_krupa") String search, Model model) {
   // model.addAttribute("message","Hello" + userName);
   SearchResults searchResults = twitter.searchOperations().search(search);
   // List<String> tweets =
   List<Tweet> tweets = searchResults.getTweets();
   // .stream()
   // .map(Tweet::getText)
   // .collect(Collectors.toList());
   model.addAttribute("tweets", tweets);
   model.addAttribute("search", search);
   // model.addAttribute("message", text);
   return "resultPage";
 }