public Cart preparCart(Item item) { List<Item> items = itemDao.getAllItem(item); BigDecimal total = new BigDecimal(0); for (Item itemX : items) { total = total.add(itemX.getTotal()); } Cart cart = new Cart(); cart.setItems(items); cart.setTotal(total); return cart; }
@RequestMapping(value = "/{user}/cancelCart", method = RequestMethod.DELETE) public @ResponseBody Cart cancelCart(@PathVariable String user) { CartBO cartBO = cartBODao.getCart(user); Item item = new Item(); item.setUser(user); item.setCartId(cartBO.getId()); List<Item> items = itemDao.getAllItem(item); for (Item itemX : items) { getItemDao().remove(itemX); } cartBODao.deleteCart(user); return new Cart(); }