Skip to content

Instantly share code, notes, and snippets.

@gbougeard
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbougeard/a22cac4b77a5dcd586be to your computer and use it in GitHub Desktop.
Save gbougeard/a22cac4b77a5dcd586be to your computer and use it in GitHub Desktop.
case class HotelQS(hotelId: Option[Long] = None,
country: Option[String] = None,
city: Option[String] = None,
zipcode: Option[String] = None)
object HotelQS {
implicit val hotelMapping: Mapping[HotelQS] =
mapping(
"hotelId" -> optional(longNumber),
"country" -> optional(text),
"city" -> optional(text),
"zipcode" -> optional(text)
)(HotelQS.apply)(HotelQS.unapply)
}
def list(filter : HotelQS, page: Int =0, orderBy: Int=0) = Action {
implicit request =>
val hotels = models.Hotels.findPage(page, orderBy, filter)
render {
case Accepts.Html() => Ok(views.html.it.hotels.list("List hotels", hotels, orderBy, filter))
case Accepts.Json() => Ok(Json.toJson(hotels))
}
}
GET /hotels controllers.Hotels.list(q:binders.HotelQS?=new binders.HotelQS, p:Int ?= 0,s:Int ?= 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment