packagecom.infy.ekart.cart.api;
importjava.util.Set;
importjavax.validation.Valid;
importjavax.validation.constraints.NotNull;
importjavax.validation.constraints.Pattern;
importorg.apache.commons.logging.Log;
importorg.apache.commons.logging.LogFactory;
importorg.springframework.beans.factory.annotation.Autowired;
importorg.springframework.core.env.Environment;
importorg.springframework.http.HttpStatus;
importorg.springframework.http.ResponseEntity;
importorg.springframework.validation.annotation.Validated;
importorg.springframework.web.bind.annotation.CrossOrigin;
importorg.springframework.web.bind.annotation.DeleteMapping;
importorg.springframework.web.bind.annotation.GetMapping;
importorg.springframework.web.bind.annotation.PathVariable;
importorg.springframework.web.bind.annotation.PostMapping;
importorg.springframework.web.bind.annotation.PutMapping;
importorg.springframework.web.bind.annotation.RequestBody;
importorg.springframework.web.bind.annotation.RequestMapping;
importorg.springframework.web.bind.annotation.RestController;
importorg.springframework.web.client.RestTemplate;
importcom.infy.ekart.cart.dto.CartProductDTO;
importcom.infy.ekart.cart.dto.CustomerCartDTO;
importcom.infy.ekart.cart.dto.ProductDTO;
importcom.infy.ekart.cart.exception.EKartCustomerCartException;
importcom.infy.ekart.cart.service.CustomerCartService;
@CrossOrigin
@RestController
@RequestMapping(value="/customercart-api")
@Validated
publicclassCustomerCartAPI{
@Autowired
privateCustomerCartServicecustomerCartService;
@Autowired
privateEnvironmentenvironment;
@Autowired
privateRestTemplatetemplate;
Loglogger=LogFactory.getLog(CustomerCartAPI.class);
@PostMapping(value="/products")
public ResponseEntity<String> addProductToCart(@Valid @RequestBody
CustomerCartDTOcustomerCartDTO)
throwsEKartCustomerCartException{
logger.info("Received a request to add products for " +
customerCartDTO.getCustomerEmailId());
IntegercartId=customerCartService.addProductToCart(customerCartDTO);