Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.00 KB | None | 0 0
  1. CONTROLLER
  2. def search(String property, String location, Integer max) {
  3.         String ipSearcherWithProxy = request.getHeader("X-FORWARDED-FOR")
  4.  
  5.         params.max = Math.min(max?.toInteger() ?: 2, 4)
  6.         def results = searchService.searchTsutseh(property, location, ipSearcherWithProxy, max)
  7.  
  8.         if (results == null) {
  9.             render(view: "/index")
  10.         }
  11.  
  12.  
  13.         respond results, model: [resultsList: results.asList(), reviews: results.review,
  14.                                    imgPath: results.images.asList(), countCards: results.size(),
  15.                                    searchV: property,
  16.                                    location: location ]
  17.     }
  18.  
  19. SERVICE
  20.  def searchTsutseh(String search, String location, String ip, Integer max) {
  21.         max = Math.min(max?.toInteger() ?: 2, 4)
  22.  
  23.         def property = Book.createCriteria()
  24.         def result = property.list (max:max, offset:
  25.             ilike('seacrh', "%${search}%")
  26.             cache true
  27.     return result
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement