public Optional<Auction> getAuction(String auctionName) { BoundStatement auctionBoundStatement = getAuction.bind(auctionName); Row auction = session.execute(auctionBoundStatement).one(); LOGGER.debug("Getting auction information for auction {} rows {}", auctionName, auction); BoundStatement bidsBound = getAuctionBids.bind(auctionName); List<BidVo> bids = session .execute(bidsBound) .all() .stream() .map( row -> new BidVo( row.getString("bid_user"), row.getLong("bid_amount"), UUIDs.unixTimestamp(row.getUUID("bid_time")))) .collect(Collectors.toList()); return Optional.of( new Auction( auction.getString("name"), Instant.ofEpochMilli(auction.getLong("ends")), bids, auction.getString("owner"))); }
public Serializable generateId(Session session) { return UUIDs.timeBased(); }
private String genUniQID() { UUID uniqueID = UUIDs.timeBased(); return uniqueID.toString(); }
public UUID placeBid(String auctionName, String user, Long amount) { UUID uuid = UUIDs.timeBased(); BoundStatement bound = storeBid.bind(auctionName, uuid, amount, user); session.execute(bound); return uuid; }