Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.7 kB
1
Indexable
Never
customerCartService.deleteProductFromCart(customerEmailId,productId);
return new
ResponseEntity<>(environment.getProperty("CustomerCartAPI.PRODUCT_DELETED_FROM_C
ART_SUCCESS"),HttpStatus.OK);
}
//Updatethequantityofproductdetailsavailableinthecartofcustomerby
//callingmodifyQuantityOfProductInCart()methodofCustomerCartService
//Settheappropriatesuccessorfailuremessageandreturnthesame
@PutMapping(value="/customer/{customerEmailId}/product/{productId}")
publicResponseEntity<String>modifyQuantityOfProductInCart(
@Pattern(regexp="[a-zA-Z0-9._]+@[a-zA-Z]{2,}\\.[a-zA-Z][a-zA-Z.]+",message=
"{invalid.customeremail.format}")@PathVariable("customerEmailId")StringcustomerEmailId,
@NotNull(message = "{invalid.email.format}") @PathVariable("productId")
IntegerproductId,
@RequestBodyIntegerquantity)throwsEKartCustomerCartException{
//writeyourlogichere
customerCartService.modifyQuantityOfProductInCart(customerEmailId, productId,
quantity);
return new
ResponseEntity<>(environment.getProperty("CustomerCartAPI.PRODUCT_QUANTITY_UPDAT
E_FROM_CART_SUCCESS"),HttpStatus.OK);
}
@DeleteMapping(value="/customer/{customerEmailId}/products")
publicResponseEntity<String>deleteAllProductsFromCart(
@Pattern(regexp="[a-zA-Z0-9._]+@[a-zA-Z]{2,}\\.[a-zA-Z][a-zA-Z.]+",message=
"{invalid.customeremail.format}")@PathVariable("customerEmailId")StringcustomerEmailId)
throwsEKartCustomerCartException{
logger.info("Receivedarequesttoclearthecartof"+customerEmailId);
customerCartService.deleteAllProductsFromCart(customerEmailId);
String message =
environment.getProperty("CustomerCartAPI.ALL_PRODUCTS_DELETED");
returnnewResponseEntity<>(message,HttpStatus.OK);
}
}