Beispiel #1
0
 public static void show(Long id) {
   System.out.printf("=== id: %d\n", id);
   List<AuctionItem> items = AuctionItem.findAll();
   for (AuctionItem item : items) {
     System.out.printf("--- id: %d\n", item.id);
   }
   AuctionItem item = AuctionItem.findById(id);
   item.viewCount++;
   item.save();
   render(item);
 }
Beispiel #2
0
  public static void newBids(Long id) {
    // count new bids
    long newBids =
        Bid.count(
            "from AuctionItem a join a.bids as b " + "where a.id = ? AND b.date > ?",
            id,
            request.date);

    // wait if needed
    if (newBids == 0) {
      await("1s");
    }

    // return the JSON output of the new bids
    AuctionItem item = AuctionItem.findById(id);

    JsonObject json = new JsonObject();
    json.addProperty("next", item.getNextBidPrice());
    json.addProperty("top", item.getCurrentTopBid());
    renderJSON(json.toString());
  }
Beispiel #3
0
 public static void showImage(Long id) {
   AuctionItem item = AuctionItem.findById(id);
   response.setContentTypeIfNotSet(item.photo.type());
   renderBinary(item.photo.get());
 }
Beispiel #4
0
 public static void showPDF(Long id) {
   AuctionItem item = AuctionItem.findById(id);
   item.viewCount++;
   item.save();
   renderPDF(item);
 }
Beispiel #5
0
 public static void addBid(Long id, Float amount) {
   AuctionItem item = AuctionItem.findById(id);
   item.addBid(amount);
   item.save();
 }