Logging bids received

This commit is contained in:
reynisson 2021-11-17 18:29:08 +01:00
parent 96b0e82113
commit 9d8e6cf216

View File

@ -2,10 +2,13 @@ package ch.unisg.tapas.auctionhouse.adapter.in.web;
import ch.unisg.tapas.auctionhouse.adapter.common.formats.AuctionJsonRepresentation;
import ch.unisg.tapas.auctionhouse.adapter.common.formats.BidJsonRepresentation;
import ch.unisg.tapas.auctionhouse.adapter.in.messaging.mqtt.BidReceivedEventListenerMqttAdapter;
import ch.unisg.tapas.auctionhouse.application.handler.BidReceivedHandler;
import ch.unisg.tapas.auctionhouse.application.port.in.BidReceivedEvent;
import ch.unisg.tapas.auctionhouse.domain.Auction;
import ch.unisg.tapas.auctionhouse.domain.Bid;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -18,6 +21,8 @@ import java.net.URI;
// TODO Fix structure due to MQTT
@RestController
public class AddBidWebController {
private static final Logger LOGGER = LogManager.getLogger(AddBidWebController.class);
@PostMapping(path = "/bid", consumes = BidJsonRepresentation.MEDIA_TYPE)
public ResponseEntity<String> addBid(@RequestBody BidJsonRepresentation payload) {
BidReceivedEvent bidReceivedEvent = new BidReceivedEvent(new Bid(
@ -27,6 +32,8 @@ public class AddBidWebController {
new Bid.BidderTaskListUri(URI.create(payload.getBidderTaskListUri()))
));
LOGGER.info("Bid received", payload);
BidReceivedHandler bidReceivedHandler = new BidReceivedHandler();
bidReceivedHandler.handleNewBidReceivedEvent(bidReceivedEvent);