This commit is contained in:
Le Deng
2017-03-10 11:36:29 -05:00
parent 303f6e93ec
commit 1fd91886ba
6 changed files with 72 additions and 13 deletions

View File

@@ -152,7 +152,7 @@
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="563">
<caret line="83" column="0" lean-forward="true" selection-start-line="83" selection-start-column="0" selection-end-line="83" selection-end-column="0" />
<caret line="104" column="60" lean-forward="false" selection-start-line="104" selection-start-column="60" selection-end-line="104" selection-end-column="60" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@@ -1038,12 +1038,12 @@
<workItem from="1488378219247" duration="650000" />
<workItem from="1488461561430" duration="18419000" />
<workItem from="1488731165185" duration="30270000" />
<workItem from="1489159532831" duration="1705000" />
<workItem from="1489159532831" duration="2499000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="93987000" />
<option name="totallyTimeSpent" value="94781000" />
</component>
<component name="ToolWindowManager">
<frame x="72" y="23" width="1280" height="797" extended-state="0" />
@@ -1067,7 +1067,7 @@
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32907802" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32624114" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32624114" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Spring" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32907802" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32229403" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
@@ -1556,7 +1556,7 @@
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="563">
<caret line="83" column="0" lean-forward="true" selection-start-line="83" selection-start-column="0" selection-end-line="83" selection-end-column="0" />
<caret line="104" column="60" lean-forward="false" selection-start-line="104" selection-start-column="60" selection-end-line="104" selection-end-column="60" />
<folding>
<element signature="imports" expanded="true" />
</folding>

View File

@@ -12,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
import java.util.HashMap;
@@ -84,4 +81,28 @@ public class ShoppingCartResource {
return shoppingCart;
}
@RequestMapping("/removeItem")
public ResponseEntity removeItem(@RequestBody String id) {
cartItemService.removeCartItem(cartItemService.findById(Long.parseLong(id)));
return new ResponseEntity("Cart Item Removed Successfully!", HttpStatus.OK);
}
@RequestMapping("/updateCartItem")
public ResponseEntity updateShoppingCart(
@RequestBody HashMap<String, String> mapper
) {
String cartItemId = mapper.get("cartItemId");
String qty = mapper.get("qty");
CartItem cartItem = cartItemService.findById(Long.parseLong(cartItemId));
cartItem.setQty(Integer.parseInt(qty));
cartItemService.updateCartItem(cartItem);
return new ResponseEntity("Cart Updated Successfully!", HttpStatus.OK);
}
}